From c08e1c0942519c06ba31981610bf7a213a68dc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Sat, 30 Mar 2024 18:31:09 -0300 Subject: [PATCH] Added language as name if available, else audio track description. --- lib/tlIO/FFmpegReadAudio.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/tlIO/FFmpegReadAudio.cpp b/lib/tlIO/FFmpegReadAudio.cpp index 252d0b85..781fcfbd 100644 --- a/lib/tlIO/FFmpegReadAudio.cpp +++ b/lib/tlIO/FFmpegReadAudio.cpp @@ -73,16 +73,20 @@ namespace tl { _avStream = i; } - + + std::string fileLanguage = "Default"; AVDictionaryEntry* tag = nullptr; unsigned trackNumber = _info.audioInfo.size() + 1; while ((tag = av_dict_get(avAudioStream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) { - std::string key(string::Format("Audio Stream #{0}: {1}") - .arg(trackNumber) - .arg(tag->key)); - tags[key] = tag->value; + const std::string& key = tag->key; + if (key == "language") + fileLanguage = tag->value; + const std::string& audio_key(string::Format("Audio Stream #{0}: {1}") + .arg(trackNumber) + .arg(key)); + tags[audio_key] = tag->value; } const size_t fileChannelCount = @@ -93,6 +97,16 @@ namespace tl const size_t fileSampleRate = avAudioCodecParameters->sample_rate; audio::Info info; + + if (fileLanguage == "und") + { + fileLanguage = string::Format("Channels: {0} {1} {2}") + .arg(fileChannelCount) + .arg(fileDataType) + .arg(fileSampleRate); + } + + info.name = fileLanguage; info.channelCount = fileChannelCount; info.dataType = fileDataType; info.sampleRate = fileSampleRate;