@@ -255,12 +255,21 @@ void Transcoder::addTranscodeStream(const std::vector<InputStreamDesc>& inputStr
255
255
<< " with encodingProfile=" << profile.at (constants::avProfileIdentificatorHuman) << std::endl
256
256
<< " and offset=" << offset << " s" )
257
257
258
- // Add input file
258
+ // Create all streams from the given inputs
259
259
std::vector<IInputStream*> inputStreams;
260
+ AVMediaType commonStreamType = AVMEDIA_TYPE_UNKNOWN;
260
261
for (std::vector<InputStreamDesc>::const_iterator it = inputStreamDescArray.begin (); it != inputStreamDescArray.end (); ++it)
261
262
{
262
263
InputFile* referenceFile = addInputFile (it->_filename , it->_streamIndex , offset);
263
264
inputStreams.push_back (&referenceFile->getStream (it->_streamIndex ));
265
+
266
+ // Check stream type
267
+ const AVMediaType currentStreamType = referenceFile->getProperties ().getStreamPropertiesWithIndex (it->_streamIndex ).getStreamType ();
268
+ if (commonStreamType == AVMEDIA_TYPE_UNKNOWN)
269
+ commonStreamType = currentStreamType;
270
+ else if (currentStreamType != commonStreamType)
271
+ throw std::runtime_error (" All the given inputs should be of the same type (video, audio...)." );
272
+
264
273
}
265
274
266
275
_streamTranscodersAllocated.push_back (
@@ -380,8 +389,10 @@ ProfileLoader::Profile Transcoder::getProfileFromInputs(const std::vector<InputS
380
389
else
381
390
{
382
391
InputFile inputFile (it->_filename );
383
- const AudioProperties& audioStream = dynamic_cast <const AudioProperties&>(inputFile.getProperties ().getStreamPropertiesWithIndex (inputStreamDesc._streamIndex ));
384
- nbChannels += audioStream.getNbChannels ();
392
+ const StreamProperties& currentStream = inputFile.getProperties ().getStreamPropertiesWithIndex (inputStreamDesc._streamIndex );
393
+ if (currentStream.getStreamType () != AVMEDIA_TYPE_AUDIO)
394
+ throw std::runtime_error (" All the given inputs should be audio streams." );
395
+ nbChannels += dynamic_cast <const AudioProperties&>(currentStream).getNbChannels ();
385
396
}
386
397
}
387
398
ss << nbChannels;
0 commit comments