File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
src/AvTranscoder/transcoder Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ ProcessStat Transcoder::process( IProgress& progress )
265
265
bool frameProcessed = true ;
266
266
while ( frameProcessed )
267
267
{
268
- const float progressDuration = _outputFile. getStream ( 0 ). getStreamDuration ();
268
+ const float progressDuration = getCurrentOutputDuration ();
269
269
270
270
// check if JobStatusCancel
271
271
if ( progress.progress ( ( progressDuration > outputDuration ) ? outputDuration : progressDuration, outputDuration ) == eJobStatusCancel )
@@ -501,6 +501,20 @@ float Transcoder::getOutputDuration() const
501
501
}
502
502
}
503
503
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
+
504
518
void Transcoder::manageSwitchToGenerator ()
505
519
{
506
520
for ( size_t i = 0 ; i < _streamTranscoders.size (); ++i )
Original file line number Diff line number Diff line change @@ -185,6 +185,13 @@ class AvExport Transcoder
185
185
*/
186
186
float getOutputDuration () const ;
187
187
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
+
188
195
/* *
189
196
* @brief Set for each StreamTranscoder if it can switch to generator at the end.
190
197
*/
You can’t perform that action at this time.
0 commit comments