@@ -105,30 +105,21 @@ bool Transcoder::processFrame()
105
105
return false ;
106
106
107
107
// For each stream, process a frame
108
- size_t nbStreamProcessStatusFailed = 0 ;
109
108
for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex)
110
109
{
111
- LOG_DEBUG (" Process stream " << streamIndex << " /" << (_streamTranscoders.size () - 1 ))
110
+ LOG_DEBUG (" Process stream " << streamIndex + 1 << " /" << _streamTranscoders.size ())
111
+
112
+ // if a stream failed to process
112
113
if (!_streamTranscoders.at (streamIndex)->processFrame ())
113
114
{
114
- LOG_WARN (" Failed to process stream " << streamIndex)
115
- ++nbStreamProcessStatusFailed;
116
- }
117
- }
118
-
119
- // Get the number of streams without the generators (they always succeed)
120
- size_t nbStreamsWithoutGenerator = _streamTranscoders.size ();
121
- for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex)
122
- {
123
- if (_streamTranscoders.at (streamIndex)->getProcessCase () == StreamTranscoder::eProcessCaseGenerator)
124
- --nbStreamsWithoutGenerator;
125
- }
115
+ LOG_WARN (" Failed to process stream at index " << streamIndex)
126
116
127
- // If all streams failed to process a new frame
128
- if (nbStreamsWithoutGenerator != 0 && nbStreamsWithoutGenerator == nbStreamProcessStatusFailed)
129
- {
130
- LOG_INFO (" End of process because all streams (except generators) failed to process a new frame." )
131
- return false ;
117
+ // if this is the end of the main stream
118
+ if (streamIndex == _mainStreamIndex) {
119
+ LOG_INFO (" End of process because the main stream at index " << _mainStreamIndex << " failed to process a new frame." )
120
+ return false ;
121
+ }
122
+ }
132
123
}
133
124
return true ;
134
125
}
@@ -174,7 +165,7 @@ ProcessStat Transcoder::process(IProgress& progress)
174
165
}
175
166
176
167
// check progressDuration
177
- if (progressDuration >= expectedOutputDuration)
168
+ if (_eProcessMethod == eProcessMethodBasedOnDuration && progressDuration >= expectedOutputDuration)
178
169
{
179
170
LOG_INFO (" End of process because the output program duration ("
180
171
<< progressDuration << " s) is equal or upper than " << expectedOutputDuration << " s." )
@@ -184,7 +175,7 @@ ProcessStat Transcoder::process(IProgress& progress)
184
175
185
176
_outputFile.endWrap ();
186
177
187
- LOG_INFO (" End of process: " << frame << " frames processed" )
178
+ LOG_INFO (" End of process: " << ++ frame << " frames processed" )
188
179
189
180
LOG_INFO (" Get process statistics" )
190
181
ProcessStat processStat;
@@ -360,32 +351,43 @@ ProfileLoader::Profile Transcoder::getProfileFromFile(InputFile& inputFile, cons
360
351
return profile;
361
352
}
362
353
363
- float Transcoder::getStreamDuration (size_t indexStream) const
354
+ float Transcoder::getStreamDuration (const size_t indexStream) const
364
355
{
365
356
return _streamTranscoders.at (indexStream)->getDuration ();
366
357
}
367
358
368
- float Transcoder::getMinTotalDuration () const
359
+ float Transcoder::getMinTotalDuration ()
369
360
{
370
361
float minTotalDuration = std::numeric_limits<float >::max ();
371
- for (size_t i = 0 ; i < _streamTranscoders.size (); ++i )
362
+ for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex )
372
363
{
373
- minTotalDuration = std::min (getStreamDuration (i), minTotalDuration);
364
+ const float streamDuration = getStreamDuration (streamIndex);
365
+ if (std::min (streamDuration, minTotalDuration) == streamDuration)
366
+ {
367
+ minTotalDuration = streamDuration;
368
+ _mainStreamIndex = streamIndex;
369
+ }
370
+
374
371
}
375
372
return minTotalDuration;
376
373
}
377
374
378
- float Transcoder::getMaxTotalDuration () const
375
+ float Transcoder::getMaxTotalDuration ()
379
376
{
380
377
float maxTotalDuration = 0 ;
381
- for (size_t i = 0 ; i < _streamTranscoders.size (); ++i )
378
+ for (size_t streamIndex = 0 ; streamIndex < _streamTranscoders.size (); ++streamIndex )
382
379
{
383
- maxTotalDuration = std::max (getStreamDuration (i), maxTotalDuration);
380
+ const float streamDuration = getStreamDuration (streamIndex);
381
+ if (std::max (streamDuration, maxTotalDuration) == streamDuration)
382
+ {
383
+ maxTotalDuration = streamDuration;
384
+ _mainStreamIndex = streamIndex;
385
+ }
384
386
}
385
387
return maxTotalDuration;
386
388
}
387
389
388
- float Transcoder::getExpectedOutputDuration () const
390
+ float Transcoder::getExpectedOutputDuration ()
389
391
{
390
392
switch (_eProcessMethod)
391
393
{
0 commit comments