File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,8 @@ class AvExport OutputFile
108
108
virtual void addMetadata ( const std::string& key, const std::string& value );
109
109
110
110
virtual void setVerbose ( bool verbose = false ){ _verbose = verbose; }
111
+
112
+ AVFormatContext& getFormatContext () { return *_formatContext; }
111
113
112
114
private:
113
115
std::vector<AvOutputStream*> _outputStreams;
Original file line number Diff line number Diff line change 6
6
#include < iostream>
7
7
#include < algorithm>
8
8
#include < sstream>
9
+ #include < libavformat/avformat.h>
9
10
10
11
namespace avtranscoder
11
12
{
@@ -310,10 +311,15 @@ void Transcoder::process( IProgress& progress )
310
311
{
311
312
if ( _verbose )
312
313
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 )
317
323
{
318
324
break ;
319
325
}
You can’t perform that action at this time.
0 commit comments