Linux: Watch a video with "Open With", yt-dlp and mpv

Add-ons for Pale Moon and other applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: Lootyhoof, FranklinDM

User avatar
Mark-PM
Apollo supporter
Apollo supporter
Posts: 36
Joined: 2024-05-12, 20:45

Linux: Watch a video with "Open With", yt-dlp and mpv

Unread post by Mark-PM » 2024-05-19, 22:48

Since i didn't find an appropriate thread here in the Add-ons forum i tinkered a solution for this in linux today.
One needs the Open With (6.8.6) extension, mpv installed on the system and the yt-dlp (from https://github.com/yt-dlp/yt-dlp or https://github.com/nicolaasjan/yt-dlp/releases).

The latter i saved in a folder eg. /home/user/utils together with a small script eg. ytdl-mpv:

Code: Select all

#!/bin/bash
/home/user/utils/yt-dlp -o - $1 | mpv -
The video file will not be stored on the disk, but the content transfered directly to mpv via stdout.
This script is to register (as usual) into the list of Open With extension.

It works nicely (in Serpent for the moment) but until now i haven't found a solution how to pass the tite of the video to mpv too, so that it's shown properly in mpv's titlebar - like usually (in Windows)...

User avatar
Mark-PM
Apollo supporter
Apollo supporter
Posts: 36
Joined: 2024-05-12, 20:45

Re: Linux: Watch a video with "Open With", yt-dlp and mpv

Unread post by Mark-PM » 2024-05-20, 16:25

Oh, that solution was too complicated as it's possible to tell mpv directly which dowloader to utilize (via mpv.conf)
as described in detail here: https://www.linuxfordevices.com/tutorials/linux/watch-youtube-videos-on-mpv-player

User avatar
andyprough
Board Warrior
Board Warrior
Posts: 1090
Joined: 2020-05-31, 04:33

Re: Linux: Watch a video with "Open With", yt-dlp and mpv

Unread post by andyprough » 2024-05-20, 22:42

Mark-PM wrote:
2024-05-20, 16:25
Oh, that solution was too complicated as it's possible to tell mpv directly which dowloader to utilize (via mpv.conf)
as described in detail here: https://www.linuxfordevices.com/tutorials/linux/watch-youtube-videos-on-mpv-player
On all the distros I've used the past couple of years mpv has used yt-dlp by default. ymmv of course.

User avatar
Mark-PM
Apollo supporter
Apollo supporter
Posts: 36
Joined: 2024-05-12, 20:45

Re: Linux: Watch a video with "Open With", yt-dlp and mpv

Unread post by Mark-PM » 2024-05-21, 20:54

My distro is a bit older, based on Debian Bullseye: the mpv installed here is 3 years old and utilizes youtube-dl.
Unfortunately the directive ytdl_hook-ytdl_path isn't yet recognized.
So i substituted the youtube-dl (in /usr/bin) with a recent yt-dlp as a kind of workaround.

User avatar
andyprough
Board Warrior
Board Warrior
Posts: 1090
Joined: 2020-05-31, 04:33

Re: Linux: Watch a video with "Open With", yt-dlp and mpv

Unread post by andyprough » 2024-05-21, 21:26

Mark-PM wrote:
2024-05-21, 20:54
My distro is a bit older, based on Debian Bullseye: the mpv installed here is 3 years old and utilizes youtube-dl.
Unfortunately the directive ytdl_hook-ytdl_path isn't yet recognized.
So i substituted the youtube-dl (in /usr/bin) with a recent yt-dlp as a kind of workaround.
Ah yes, I used to do that. Just make sure you are using the latest yt-dlp from github and not some ancient version from Debian or it won't work well.

User avatar
nicolaasjan
Moon lover
Moon lover
Posts: 97
Joined: 2017-07-28, 14:44
Location: the Netherlands

Re: Linux: Watch a video with "Open With", yt-dlp and mpv

Unread post by nicolaasjan » 2024-05-22, 18:27

On an older system, it is also beneficial to tell yt-dlp to fetch AVC codec (h264), in order to take advantage of hardware decoding.
In ~/.config/mpv put:

Code: Select all

ytdl-format="bestvideo[height<=1080][ext=mp4][vcodec^=avc]+bestaudio[ext=m4a]/best[ext=mp4]/best"
hwdec=auto
You can find an example mpv.conf file at:
https://github.com/mpv-player/mpv/blob/master/etc/mpv.conf
So i substituted the youtube-dl (in /usr/bin) with a recent yt-dlp as a kind of workaround.
It's easier to make a symlink to yt-dlp and name it youtube-dl.
Then you don't have to rename it each time after an update with sudo yt-dlp -U
Linux Mint 21.3 MATE 64bit
Pale Moon latest

User avatar
Mark-PM
Apollo supporter
Apollo supporter
Posts: 36
Joined: 2024-05-12, 20:45

Re: Linux: Watch a video with "Open With", yt-dlp and mpv

Unread post by Mark-PM » 2024-05-23, 13:43

Hey @nicolaasjan, so pleased to meet you here! :P

To be honest, i was about to contact you in the ,other' forum in this regard, however, since this issue is more Linux-specific i desisted from doing so.
Many thanks for the hints, both very useful: symlinks are new to me but i'll implement this solution very soon...

Kindest regards!

gabrgv
Moonbather
Moonbather
Posts: 54
Joined: 2023-10-28, 18:59

Re: Linux: Watch a video with "Open With", yt-dlp and mpv

Unread post by gabrgv » 2024-07-06, 18:18

There is an extension called “Watch with MPV” in the Classic Add-ons Archive that does exactly that. You can download it from here too.