Skip to content

Commit 362bf2b

Browse files
committed
Merge pull request #9 from valnoel/fix_transcoder_progress_computing
Fix transcoder progress computing
2 parents 0e8513a + 6eb4b0a commit 362bf2b

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,13 @@ void OutputFile::setProfile( const ProfileLoader::Profile& profile )
291291
}
292292
}
293293

294+
double OutputFile::getProgressDuration()
295+
{
296+
AVStream* firstOutputStream = _formatContext->streams[0];
297+
if( firstOutputStream == NULL )
298+
throw std::runtime_error( "at least one stream must be set to get the progress duration" );
299+
double duration = av_q2d( firstOutputStream->time_base ) * firstOutputStream->cur_dts;
300+
return duration;
301+
}
302+
294303
}

src/AvTranscoder/file/OutputFile.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class AvExport OutputFile
109109

110110
virtual void setVerbose( bool verbose = false ){ _verbose = verbose; }
111111

112-
AVFormatContext& getFormatContext() { return *_formatContext; }
112+
double getProgressDuration();
113113

114114
private:
115115
std::vector<AvOutputStream*> _outputStreams;

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,7 @@ void Transcoder::process( IProgress& progress )
317317
if( ! frameProcessed )
318318
break;
319319

320-
AVStream* firstOutputStream = _outputFile.getFormatContext().streams[0];
321-
double duration = av_q2d( firstOutputStream->time_base ) * firstOutputStream->cur_dts;
322-
323-
if( progress.progress( duration, totalDuration ) == eJobStatusCancel )
320+
if( progress.progress( _outputFile.getProgressDuration(), totalDuration ) == eJobStatusCancel )
324321
{
325322
break;
326323
}

0 commit comments

Comments
 (0)