aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Youtube.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-14 08:54:55 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-14 08:54:55 +0200
commit2c0347ff7a13896dcc64c1deb4447449790bad73 (patch)
tree9d12802eef11fda8646454e6e79e25546359181f /src/plugins/Youtube.cpp
parentd37b3a7aac87e5f60c49202c824d985e53b7b544 (diff)
Workaround shitty mpv pulseaudio issue where the video is frozen. Try reloading video on failure to load
Diffstat (limited to 'src/plugins/Youtube.cpp')
-rw-r--r--src/plugins/Youtube.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 49d7b83..1f8c103 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -1864,29 +1864,31 @@ namespace QuickMedia {
return "";
}
+ const YoutubeVideoFormat *chosen_video_format = nullptr;
const YoutubeVideoFormat *best_mp4 = get_highest_resolution_mp4_non_av1(video_formats, max_height);
const YoutubeVideoFormat *best_non_mp4 = get_highest_resolution_non_mp4(video_formats, max_height);
// We prefer mp4 (h264) because it has the best hardware decoding support
if(best_mp4 && (!best_non_mp4 || (best_mp4->height >= best_non_mp4->height && best_mp4->fps >= best_non_mp4->fps))) {
- print_chosen_format(*best_mp4);
- has_embedded_audio = best_mp4->has_embedded_audio;
- return best_mp4->base.url;
+ chosen_video_format = best_mp4;
} else if(best_non_mp4) {
- print_chosen_format(*best_non_mp4);
- has_embedded_audio = best_non_mp4->has_embedded_audio;
- return best_non_mp4->base.url;
+ chosen_video_format = best_non_mp4;
}
+
+ if(!chosen_video_format)
+ chosen_video_format = &video_formats.back();
- print_chosen_format(video_formats.back());
- has_embedded_audio = video_formats.back().has_embedded_audio;
- return video_formats.back().base.url;
+ print_chosen_format(*chosen_video_format);
+ has_embedded_audio = chosen_video_format->has_embedded_audio;
+ return chosen_video_format->base.url;
}
std::string YoutubeVideoPage::get_audio_url() {
if(audio_formats.empty())
return "";
- return audio_formats.front().base.url;
+ const YoutubeAudioFormat *chosen_audio_format = &audio_formats.front();
+ fprintf(stderr, "Choosing youtube audio format: bitrate: %d, mime type: %s\n", chosen_audio_format->base.bitrate, chosen_audio_format->base.mime_type.c_str());
+ return chosen_audio_format->base.url;
}
PluginResult YoutubeVideoPage::load(std::string &title, std::string &channel_url) {