@@ -393,16 +393,26 @@ void Transcoder::addTranscodeStream( const std::string& filename, const size_t s
393
393
// Create profile as input configuration
394
394
NoDisplayProgress progress;
395
395
referenceFile->analyse ( progress, eAnalyseLevelHeader );
396
- AudioProperties audioProperties = referenceFile->getProperties ().getAudioProperties ().at ( streamIndex );
396
+
397
+ const AudioProperties* audioProperties = NULL ;
398
+ for ( size_t i = 0 ; i < referenceFile->getProperties ().getAudioProperties ().size (); i++ )
399
+ {
400
+ if ( referenceFile->getProperties ().getAudioProperties ().at ( i ).getStreamId () == streamIndex )
401
+ {
402
+ audioProperties = &referenceFile->getProperties ().getAudioProperties ().at ( i );
403
+ }
404
+ }
405
+ if ( audioProperties == NULL )
406
+ throw std::runtime_error ( " cannot set audio stream properties" );
397
407
398
408
ProfileLoader::Profile profile;
399
409
profile[ constants::avProfileIdentificator ] = " presetRewrap" ;
400
410
profile[ constants::avProfileIdentificatorHuman ] = " Preset rewrap" ;
401
411
profile[ constants::avProfileType ] = avtranscoder::constants::avProfileTypeAudio;
402
- profile[ constants::avProfileCodec ] = audioProperties. getCodecName ();
403
- profile[ constants::avProfileSampleFormat ] = audioProperties. getSampleFormatName ();
412
+ profile[ constants::avProfileCodec ] = audioProperties-> getCodecName ();
413
+ profile[ constants::avProfileSampleFormat ] = audioProperties-> getSampleFormatName ();
404
414
std::stringstream ss;
405
- ss << audioProperties. getSampleRate ();
415
+ ss << audioProperties-> getSampleRate ();
406
416
profile[ constants::avProfileSampleRate ] = ss.str ();
407
417
profile[ constants::avProfileChannel ] = " 1" ;
408
418
0 commit comments