diff --git a/lib/tlCore/Audio.h b/lib/tlCore/Audio.h index b27a2275..399adb93 100644 --- a/lib/tlCore/Audio.h +++ b/lib/tlCore/Audio.h @@ -110,6 +110,7 @@ namespace tl size_t channelCount = 0; DataType dataType = DataType::None; size_t sampleRate = 0; + unsigned audioTracks = 1; //! Is the audio valid? bool isValid() const; diff --git a/lib/tlIO/FFmpegReadAudio.cpp b/lib/tlIO/FFmpegReadAudio.cpp index be6e83c7..ca42949b 100644 --- a/lib/tlIO/FFmpegReadAudio.cpp +++ b/lib/tlIO/FFmpegReadAudio.cpp @@ -59,13 +59,16 @@ namespace tl { throw std::runtime_error(string::Format("{0}: {1}").arg(fileName).arg(getErrorLabel(r))); } + unsigned int audioTracks = 0; for (unsigned int i = 0; i < _avFormatContext->nb_streams; ++i) { - if (AVMEDIA_TYPE_AUDIO == _avFormatContext->streams[i]->codecpar->codec_type && - AV_DISPOSITION_DEFAULT == _avFormatContext->streams[i]->disposition) + if (AVMEDIA_TYPE_AUDIO == _avFormatContext->streams[i]->codecpar->codec_type) { - _avStream = i; - break; + ++audioTracks; + if (AV_DISPOSITION_DEFAULT == _avFormatContext->streams[i]->disposition) + { + _avStream = i; + } } } if (-1 == _avStream) @@ -84,6 +87,8 @@ namespace tl { //av_dump_format(_avFormatContext, _avStream, fileName.c_str(), 0); + _info.audioTracks = audioTracks; + auto avAudioStream = _avFormatContext->streams[_avStream]; auto avAudioCodecParameters = avAudioStream->codecpar; auto avAudioCodec = avcodec_find_decoder(avAudioCodecParameters->codec_id);