Skip to content

Commit 76caaba

Browse files
author
Valentin Noel
committed
Transcoder: fix audio stream setting when demuxing without specified output profile
1 parent 265300f commit 76caaba

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,26 @@ void Transcoder::addTranscodeStream( const std::string& filename, const size_t s
393393
// Create profile as input configuration
394394
NoDisplayProgress progress;
395395
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" );
397407

398408
ProfileLoader::Profile profile;
399409
profile[ constants::avProfileIdentificator ] = "presetRewrap";
400410
profile[ constants::avProfileIdentificatorHuman ] = "Preset rewrap";
401411
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();
404414
std::stringstream ss;
405-
ss << audioProperties.getSampleRate();
415+
ss << audioProperties->getSampleRate();
406416
profile[ constants::avProfileSampleRate ] = ss.str();
407417
profile[ constants::avProfileChannel ] = "1";
408418

0 commit comments

Comments
 (0)