Skip to content

Commit 9137c01

Browse files
committed
Merge pull request #236 from cchampet/pyrewrap_addAudio
pyrewrap app: add audio stream to the wrapping process
2 parents 586d31a + 6d1fcd7 commit 9137c01

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

app/pyRewrap/pyrewrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def addStreamsToTranscoder(transcoder, streams):
7777
transcoder.add( args.inputFileName, stIndex )
7878

7979
addStreamsToTranscoder(transcoder, inputFile.getProperties().getVideoProperties())
80-
# addStreamsToTranscoder(transcoder, inputFile.getProperties().getAudioProperties())
80+
addStreamsToTranscoder(transcoder, inputFile.getProperties().getAudioProperties())
8181
# addStreamsToTranscoder(transcoder, inputFile.getProperties().getDataProperties())
8282

8383
# launch process

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ int VideoProperties::getLevel() const
516516

517517
float VideoProperties::getFps() const
518518
{
519-
Rational timeBase = getTimeBase();
520-
float fps = timeBase.den / (double) timeBase.num;
519+
const Rational timeBase = getTimeBase();
520+
const float fps = timeBase.den / (double) timeBase.num;
521521
if( std::isinf( fps ) )
522522
{
523523
std::ostringstream os;

src/AvTranscoder/mediaProperty/VideoProperties.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ class AvExport VideoProperties : public StreamProperties
5555
int getProfile() const;
5656
int getLevel() const;
5757

58+
/**
59+
* @brief Corresponds to the compute of the 'tbn' by ffmpeg.
60+
* tbn = the time base in AVStream that has come from the container
61+
* tbc = the time base in AVCodecContext for the codec used for a particular stream
62+
* tbr = tbr is guessed from the video stream and is the value users want to see when they look for the video frame rate
63+
* @return
64+
*/
5865
float getFps() const;
5966

6067
bool hasBFrames() const;

src/AvTranscoder/stream/OutputStream.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ OutputStream::OutputStream( OutputFile& outputFile, const size_t streamIndex )
1616

1717
float OutputStream::getStreamDuration() const
1818
{
19-
AVStream& outputStream = _outputFile->getFormatContext().getAVStream( _streamIndex );
19+
const AVStream& outputStream = _outputFile->getFormatContext().getAVStream( _streamIndex );
20+
21+
// check floating point exception
22+
if( outputStream.time_base.den == 0 || outputStream.pts.den == 0 )
23+
{
24+
LOG_WARN( "Cannot compute stream duration of output stream at index " << _streamIndex )
25+
return 0.f;
26+
}
27+
2028
#if AVTRANSCODER_FFMPEG_DEPENDENCY && LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(55, 40, 100)
2129
// returns the pts of the last muxed packet, converted from timebase to seconds
2230
return av_q2d( outputStream.time_base ) * av_stream_get_end_pts( &outputStream );

0 commit comments

Comments
 (0)