diff --git a/src/AvTranscoder/file/OutputFile.hpp b/src/AvTranscoder/file/OutputFile.hpp index e94c5f40..fb49717c 100644 --- a/src/AvTranscoder/file/OutputFile.hpp +++ b/src/AvTranscoder/file/OutputFile.hpp @@ -108,6 +108,8 @@ class AvExport OutputFile virtual void addMetadata( const std::string& key, const std::string& value ); virtual void setVerbose( bool verbose = false ){ _verbose = verbose; } + + AVFormatContext& getFormatContext() { return *_formatContext; } private: std::vector _outputStreams; diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index 2ee022a6..5ce9a8db 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace avtranscoder { @@ -310,10 +311,15 @@ void Transcoder::process( IProgress& progress ) { if( _verbose ) std::cout << "process frame " << frame << std::endl; - if( ! processFrame() ) - break; - - if( progress.progress( 1 / _outputFps * ( frame ), totalDuration ) == eJobStatusCancel ) + + bool frameProcessed = processFrame(); + if( ! frameProcessed ) + break; + + AVStream* firstOutputStream = _outputFile.getFormatContext().streams[0]; + double duration = av_q2d( firstOutputStream->time_base ) * firstOutputStream->cur_dts; + + if( progress.progress( duration, totalDuration ) == eJobStatusCancel ) { break; }