diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-01-25 16:52:35 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-01-25 16:52:35 +0100 |
commit | 0d7ce5264e8c87c522a93172c944541bb205b9d5 (patch) | |
tree | 3fe19f12d96c1bf830f777e101e37edfedd0b80d /src/VideoPlayer.cpp | |
parent | 82d4273e445b85e15fe12caaa52c301fa77aaa6c (diff) |
Limit ytdl video resolution to the largest monitors height
Diffstat (limited to 'src/VideoPlayer.cpp')
-rw-r--r-- | src/VideoPlayer.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index bc37710..4653c5b 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -18,7 +18,7 @@ const int MAX_RETRIES_CONNECT = 1000; const int READ_TIMEOUT_MS = 200; namespace QuickMedia { - VideoPlayer::VideoPlayer(bool use_tor, bool no_video, bool use_system_mpv_config, bool resume_playback, bool keep_open, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback, const std::string &resource_root) : + VideoPlayer::VideoPlayer(bool use_tor, bool no_video, bool use_system_mpv_config, bool resume_playback, bool keep_open, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback, const std::string &resource_root, int monitor_height) : exit_status(0), use_tor(use_tor), no_video(no_video), @@ -30,6 +30,7 @@ namespace QuickMedia { connected_to_ipc(false), connect_tries(0), find_window_tries(0), + monitor_height(monitor_height), event_callback(_event_callback), window_create_callback(_window_create_callback), window_handle(0), @@ -44,6 +45,7 @@ namespace QuickMedia { display = XOpenDisplay(NULL); if (!display) throw std::runtime_error("Failed to open display to X11 server"); + fprintf(stderr, "Video max height: %d\n", monitor_height); } VideoPlayer::~VideoPlayer() { @@ -89,6 +91,8 @@ namespace QuickMedia { create_directory_recursive(mpv_watch_later_dir); std::string watch_later_dir = "--watch-later-directory=" + mpv_watch_later_dir.data; + std::string ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best"; + // TODO: Resume playback if the last video played matches the first video played next time QuickMedia is launched args.insert(args.end(), { "mpv", @@ -101,6 +105,9 @@ namespace QuickMedia { watch_later_dir.c_str(), "--cache-on-disk=yes", "--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub=", + ytdl_format.c_str(), + // TODO: Disable hr seek on low power devices? + "--hr-seek=yes", input_conf.c_str(), wid_arg.c_str() }); |