Skip to content

Commit

Permalink
Multichannel WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Mar 11, 2024
1 parent 9245ef0 commit 3af4a01
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/tlCore/Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions lib/tlIO/FFmpegReadAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down

0 comments on commit 3af4a01

Please sign in to comment.