Skip to content

Commit 0b16a95

Browse files
committed
Merge pull request #133 from valnoel/fix_progress_bar_length
Fix progress bar length
2 parents a078157 + cf43b3b commit 0b16a95

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/AvTranscoder/file/OutputFile.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ class AvExport OutputFile
108108
virtual void addMetadata( const std::string& key, const std::string& value );
109109

110110
virtual void setVerbose( bool verbose = false ){ _verbose = verbose; }
111+
112+
AVFormatContext& getFormatContext() { return *_formatContext; }
111113

112114
private:
113115
std::vector<AvOutputStream*> _outputStreams;

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <iostream>
77
#include <algorithm>
88
#include <sstream>
9+
#include <libavformat/avformat.h>
910

1011
namespace avtranscoder
1112
{
@@ -310,10 +311,15 @@ void Transcoder::process( IProgress& progress )
310311
{
311312
if( _verbose )
312313
std::cout << "process frame " << frame << std::endl;
313-
if( ! processFrame() )
314-
break;
315-
316-
if( progress.progress( 1 / _outputFps * ( frame ), totalDuration ) == eJobStatusCancel )
314+
315+
bool frameProcessed = processFrame();
316+
if( ! frameProcessed )
317+
break;
318+
319+
AVStream* firstOutputStream = _outputFile.getFormatContext().streams[0];
320+
double duration = av_q2d( firstOutputStream->time_base ) * firstOutputStream->cur_dts;
321+
322+
if( progress.progress( duration, totalDuration ) == eJobStatusCancel )
317323
{
318324
break;
319325
}

0 commit comments

Comments
 (0)