From 8c4e3217bf3e3c675f181c34f79448ba036dfcaf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 2 Sep 2021 23:07:50 +0200 Subject: Youtube: skip non-default audio tracks, remove subtitle shadow --- src/plugins/Youtube.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index 6a96595..34fd250 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -2590,7 +2590,7 @@ R"END( codecs_p += 8; const char *codecs_sep_p = strchr(codecs_p, ','); const char *codecs_end_p = strchr(codecs_p, '"'); - has_embedded_audio = (codecs_sep_p != nullptr && (!codecs_end_p || codecs_sep_p < codecs_end_p)); + has_embedded_audio = (codecs_sep_p && (!codecs_end_p || codecs_sep_p < codecs_end_p)); } YoutubeVideoFormat video_format; @@ -2619,6 +2619,15 @@ R"END( video_formats.push_back(std::move(video_format)); } else if(strncmp(youtube_format_base.mime_type.c_str(), "audio/", 6) == 0) { + // Some youtube videos have multiple audio tracks and sometimes the audio tracks are in the same language + // and one audio track may be descriptive/commentary. We only want the original audio for now + const Json::Value &audio_track_json = format["audioTrack"]; + if(audio_track_json.isObject()) { + const Json::Value &audio_is_default_json = audio_track_json["audioIsDefault"]; + if(audio_is_default_json.isBool() && !audio_is_default_json.asBool()) + continue; + } + YoutubeAudioFormat audio_format; audio_format.base = std::move(youtube_format_base); -- cgit v1.2.3