@@ -235,30 +235,21 @@ bool Transcoder::processFrame()
235
235
return false ;
236
236
237
237
// For each stream, process a frame
238
- size_t nbStreamProcessStatusFailed = 0 ;
239
238
for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex)
240
239
{
241
- LOG_DEBUG (" Process stream " << streamIndex << " /" << (_streamTranscoders.size () - 1 ))
240
+ LOG_DEBUG (" Process stream " << streamIndex + 1 << " /" << _streamTranscoders.size ())
241
+
242
+ // if a stream failed to process
242
243
if (!_streamTranscoders.at (streamIndex)->processFrame ())
243
244
{
244
- LOG_WARN (" Failed to process stream " << streamIndex)
245
- ++nbStreamProcessStatusFailed;
246
- }
247
- }
248
-
249
- // Get the number of streams without the generators (they always succeed)
250
- size_t nbStreamsWithoutGenerator = _streamTranscoders.size ();
251
- for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex)
252
- {
253
- if (_streamTranscoders.at (streamIndex)->getProcessCase () == StreamTranscoder::eProcessCaseGenerator)
254
- --nbStreamsWithoutGenerator;
255
- }
245
+ LOG_WARN (" Failed to process stream at index " << streamIndex)
256
246
257
- // If all streams failed to process a new frame
258
- if (nbStreamsWithoutGenerator != 0 && nbStreamsWithoutGenerator == nbStreamProcessStatusFailed)
259
- {
260
- LOG_INFO (" End of process because all streams (except generators) failed to process a new frame." )
261
- return false ;
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
+ }
252
+ }
262
253
}
263
254
return true ;
264
255
}
@@ -304,7 +295,7 @@ ProcessStat Transcoder::process(IProgress& progress)
304
295
}
305
296
306
297
// check progressDuration
307
- if (progressDuration >= expectedOutputDuration)
298
+ if (_eProcessMethod == eProcessMethodBasedOnDuration && progressDuration >= expectedOutputDuration)
308
299
{
309
300
LOG_INFO (" End of process because the output program duration ("
310
301
<< progressDuration << " s) is equal or upper than " << expectedOutputDuration << " s." )
@@ -314,7 +305,7 @@ ProcessStat Transcoder::process(IProgress& progress)
314
305
315
306
_outputFile.endWrap ();
316
307
317
- LOG_INFO (" End of process: " << frame << " frames processed" )
308
+ LOG_INFO (" End of process: " << ++ frame << " frames processed" )
318
309
319
310
LOG_INFO (" Get process statistics" )
320
311
ProcessStat processStat;
@@ -498,32 +489,43 @@ ProfileLoader::Profile Transcoder::getProfileFromFile(InputFile& inputFile, cons
498
489
return profile;
499
490
}
500
491
501
- float Transcoder::getStreamDuration (size_t indexStream) const
492
+ float Transcoder::getStreamDuration (const size_t indexStream) const
502
493
{
503
494
return _streamTranscoders.at (indexStream)->getDuration ();
504
495
}
505
496
506
- float Transcoder::getMinTotalDuration () const
497
+ float Transcoder::getMinTotalDuration ()
507
498
{
508
499
float minTotalDuration = std::numeric_limits<float >::max ();
509
- for (size_t i = 0 ; i < _streamTranscoders.size (); ++i )
500
+ for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex )
510
501
{
511
- minTotalDuration = std::min (getStreamDuration (i), minTotalDuration);
502
+ const float streamDuration = getStreamDuration (streamIndex);
503
+ if (std::min (streamDuration, minTotalDuration) == streamDuration)
504
+ {
505
+ minTotalDuration = streamDuration;
506
+ _mainStreamIndex = streamIndex;
507
+ }
508
+
512
509
}
513
510
return minTotalDuration;
514
511
}
515
512
516
- float Transcoder::getMaxTotalDuration () const
513
+ float Transcoder::getMaxTotalDuration ()
517
514
{
518
515
float maxTotalDuration = 0 ;
519
- for (size_t i = 0 ; i < _streamTranscoders.size (); ++i )
516
+ for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex )
520
517
{
521
- maxTotalDuration = std::max (getStreamDuration (i), maxTotalDuration);
518
+ const float streamDuration = getStreamDuration (streamIndex);
519
+ if (std::max (streamDuration, maxTotalDuration) == streamDuration)
520
+ {
521
+ maxTotalDuration = streamDuration;
522
+ _mainStreamIndex = streamIndex;
523
+ }
522
524
}
523
525
return maxTotalDuration;
524
526
}
525
527
526
- float Transcoder::getExpectedOutputDuration () const
528
+ float Transcoder::getExpectedOutputDuration ()
527
529
{
528
530
switch (_eProcessMethod)
529
531
{
0 commit comments