From 0c8ea5275b83af28b3ed2576fdd5a3e5cee400df Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 13 May 2020 06:02:49 +0000 Subject: [PATCH] [mpv] Add quality limit to browser streams Sending links to mpv limits the quality to 1080p, to be able to stream it with my connection, and since I can not display more. Fixed mpv taking ages to open for ytdl streams. (or anything else which takes a while to load) Mpv had to wait until it had enough buffer to begin playing and only then would open its main window. With this fix it immediately opens the window, and starts playing whenever it is ready. --- {scripts => mpv}/.local/bin/umpv | 2 +- qutebrowser/.config/qutebrowser/config.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) rename {scripts => mpv}/.local/bin/umpv (97%) diff --git a/scripts/.local/bin/umpv b/mpv/.local/bin/umpv similarity index 97% rename from scripts/.local/bin/umpv rename to mpv/.local/bin/umpv index 0080b44..2053aa0 100755 --- a/scripts/.local/bin/umpv +++ b/mpv/.local/bin/umpv @@ -90,7 +90,7 @@ else: os.mkfifo(FIFO, 0o600) opts = (os.getenv("MPV") or "mpv").split() - opts.extend(["--no-terminal", "--force-window", "--input-file=" + FIFO, + opts.extend(["--no-terminal", "--force-window=immediate", "--input-file=" + FIFO, "--"]) opts.extend(files) diff --git a/qutebrowser/.config/qutebrowser/config.py b/qutebrowser/.config/qutebrowser/config.py index b08e47c..2f4ccc9 100644 --- a/qutebrowser/.config/qutebrowser/config.py +++ b/qutebrowser/.config/qutebrowser/config.py @@ -91,8 +91,9 @@ config.bind(leader + 'tV', 'set tabs.position left') # [M]edia shortcuts - watch, queue, download media # bind mpv to play the current page/links, using a single instance which queues the next link passed -config.bind(leader + 'M', 'spawn umpv {url}') -config.bind(leader + 'm', 'hint links spawn umpv {hint-url}') +streamingformat = '--ytdl-format="bestvideo[height<=1080]+bestaudio/best[height<=1080]"' +config.bind(leader + 'M', 'spawn umpv ' + streamingformat + ' {url}') +config.bind(leader + 'm', 'hint links spawn umpv ' + streamingformat + ' {hint-url}') # bind youtube-dl to download the current page/links config.bind(leader + 'dM', 'spawn youtube-dl -o ~/videos/%(title)s.%(ext)s {url}') config.bind(leader + 'dm', 'hint --rapid links spawn youtube-dl -o ~/videos/%(title)s.%(ext)s {url}')