@@ -243,6 +243,12 @@ bool Transcoder::processFrame()
243
243
{
244
244
LOG_WARN (" Failed to process stream " << streamIndex)
245
245
++nbStreamProcessStatusFailed;
246
+
247
+ // if this is the end of the main stream
248
+ if (streamIndex == _mainStreamIndex) {
249
+ LOG_INFO (" End of process because the main stream at index " << _mainStreamIndex << " failed to process a new frame." )
250
+ return false ;
251
+ }
246
252
}
247
253
}
248
254
@@ -302,14 +308,6 @@ ProcessStat Transcoder::process(IProgress& progress)
302
308
LOG_INFO (" End of process because the job was canceled." )
303
309
break ;
304
310
}
305
-
306
- // check progressDuration
307
- if (progressDuration >= expectedOutputDuration)
308
- {
309
- LOG_INFO (" End of process because the output program duration ("
310
- << progressDuration << " s) is equal or upper than " << expectedOutputDuration << " s." )
311
- break ;
312
- }
313
311
}
314
312
315
313
_outputFile.endWrap ();
@@ -498,32 +496,43 @@ ProfileLoader::Profile Transcoder::getProfileFromFile(InputFile& inputFile, cons
498
496
return profile;
499
497
}
500
498
501
- float Transcoder::getStreamDuration (size_t indexStream) const
499
+ float Transcoder::getStreamDuration (const size_t indexStream) const
502
500
{
503
501
return _streamTranscoders.at (indexStream)->getDuration ();
504
502
}
505
503
506
- float Transcoder::getMinTotalDuration () const
504
+ float Transcoder::getMinTotalDuration ()
507
505
{
508
506
float minTotalDuration = std::numeric_limits<float >::max ();
509
- for (size_t i = 0 ; i < _streamTranscoders.size (); ++i )
507
+ for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex )
510
508
{
511
- minTotalDuration = std::min (getStreamDuration (i), minTotalDuration);
509
+ const float streamDuration = getStreamDuration (streamIndex);
510
+ if (std::min (streamDuration, minTotalDuration) == streamDuration)
511
+ {
512
+ minTotalDuration = streamDuration;
513
+ _mainStreamIndex = streamIndex;
514
+ }
515
+
512
516
}
513
517
return minTotalDuration;
514
518
}
515
519
516
- float Transcoder::getMaxTotalDuration () const
520
+ float Transcoder::getMaxTotalDuration ()
517
521
{
518
522
float maxTotalDuration = 0 ;
519
- for (size_t i = 0 ; i < _streamTranscoders.size (); ++i )
523
+ for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex )
520
524
{
521
- maxTotalDuration = std::max (getStreamDuration (i), maxTotalDuration);
525
+ const float streamDuration = getStreamDuration (streamIndex);
526
+ if (std::max (streamDuration, maxTotalDuration) == streamDuration)
527
+ {
528
+ maxTotalDuration = streamDuration;
529
+ _mainStreamIndex = streamIndex;
530
+ }
522
531
}
523
532
return maxTotalDuration;
524
533
}
525
534
526
- float Transcoder::getExpectedOutputDuration () const
535
+ float Transcoder::getExpectedOutputDuration ()
527
536
{
528
537
switch (_eProcessMethod)
529
538
{
0 commit comments