Skip to content

Commit 087c3aa

Browse files
author
Clement Champetier
committed
Transcoder: fixed how to get the progressDuration during a process
Added getCurrentOutputDuration private method.
1 parent 95d9d42 commit 087c3aa

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ ProcessStat Transcoder::process( IProgress& progress )
265265
bool frameProcessed = true;
266266
while( frameProcessed )
267267
{
268-
const float progressDuration = _outputFile.getStream( 0 ).getStreamDuration();
268+
const float progressDuration = getCurrentOutputDuration();
269269

270270
// check if JobStatusCancel
271271
if( progress.progress( ( progressDuration > outputDuration ) ? outputDuration : progressDuration, outputDuration ) == eJobStatusCancel )
@@ -501,6 +501,20 @@ float Transcoder::getOutputDuration() const
501501
}
502502
}
503503

504+
float Transcoder::getCurrentOutputDuration() const
505+
{
506+
float currentOutputDuration = -1;
507+
for( size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex )
508+
{
509+
const float currentStreamDuration = _outputFile.getStream( streamIndex ).getStreamDuration();
510+
if( currentOutputDuration == -1 )
511+
currentOutputDuration = currentStreamDuration;
512+
else if( currentStreamDuration < currentOutputDuration )
513+
currentOutputDuration = currentStreamDuration;
514+
}
515+
return currentOutputDuration;
516+
}
517+
504518
void Transcoder::manageSwitchToGenerator()
505519
{
506520
for( size_t i = 0; i < _streamTranscoders.size(); ++i )

src/AvTranscoder/transcoder/Transcoder.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ class AvExport Transcoder
185185
*/
186186
float getOutputDuration() const;
187187

188+
/**
189+
* @brief Get the current duration of the output program
190+
* @note Returns the duration of the smallest stream.
191+
* @return -1 if there is no output stream.
192+
*/
193+
float getCurrentOutputDuration() const;
194+
188195
/**
189196
* @brief Set for each StreamTranscoder if it can switch to generator at the end.
190197
*/

0 commit comments

Comments
 (0)