Firefox 98 play-with MPV, yt-dlp, and cleanup

For those that are running Firefox 98 and facing problems with hw acceleration and decided not to downgrade due to the security fixes in 98:

Install this extension: Play-with… https://github.com/grmat/play-with
Then, install youtube-dlp https://archlinux.org/packages/community/any/yt-dlp/, this is a fork from youtube-dl which is not working properly, it keeps buffering for ever…

Enable hw accel in mpv:

$ cat ~/.config/mpv/mpv.conf 
# Enable hw decoder
hwdec=auto

Optional:
You will notice that each video you watch, there will be a .m3u or .m3u8 file downloaded.
So, to clean these files automatically, I created a systemctl timer/service:

~/.config/systemd/user
m3u.timer
[Unit]
Description=Timer to cleanup *.m3u* files from play-with (MPV)

[Timer]
OnCalendar=hourly
Persistent=true
OnBootSec=3min

[Install]
WantedBy=timers.target
m3u.service
[Unit]
Description=Service to cleanup *.m3u* files from play-with (MPV)
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'rm /path/firefox/download/directory/*.m3u8'
[Install]
WantedBy=default.target

Then, enable the services:

systemctl --user enable --now m3u.timer
3 Likes

For those who have firefox set to download but not prompt each time, there are some more solutions:

#1. Use add-on and a small native app (native-messaging):

ff2mpv

Install the FF add-in ff2mpv and either ff2mpv-native-messaging-host-git or ff2mpv-go-git

#2. Small shell-script opening mpv (or whatever else you want) with URL from clipboard

script
#!/bin/sh

notify-send -t 3000 --icon=video-television "Playing video" "$(xclip -selection clipboard -o)";
mpv "$(xclip -selection clipboard -o)" --osd-level=1

F.e. with i3:
bindsym $mod+y exec scripts/playVideo

  • Visit website with video
  • Copy the URL to the clipboard
  • Press your shortcut keys
4 Likes

If you can download something with yt-dlp why would you watch it in a browser?

Just download the video with yt-dlp and view it offline using a media player.

1 Like

You download a 50 bytes file, like a playlist, and it plays instantly through mpv
So, its a right click in the video, select play with mpv, the file plays instantly, after that, the 50 bytes file download .m3u8 is deleted by the service/timer mentioned above…

Sorry, can I explain why it is necessary?
You can simply open the MPV and drag the link to the video.

Well, depends on setup/workflow.
Using a tiling WM, I tend to prefer keyboard shortcuts instead mouse interactions like drag/drop/click. It’s just way more convenient if you have mpv bound to specific workspace/monitor etc.

1 Like

For me, its easier, faster, cleaner then keeping a mpv window opened, drag videos around… just right click and play it, mpv open then mpv closes…

With the configuration below, the video starts in the corner, with 0.4 of its size, so I can keep doing my things while the video is playing, I press ALT + UP or ALT + DOWN to change the video size, keep on top, double click for fullscreen and etc…

cat ~/.config/mpv.input.conf
` cycle border
ALT+UP add window-scale 0.05
ALT+DOWN add window-scale -0.05
b script-message osc-visibility never
a script-message osc-visibility auto
cat ~/.config/mpv/mpv.conf
# Enable hw decoder
hwdec=auto
# Wayland
gpu-context=wayland
# Quality settings
profile=gpu-hq
scale=ewa_lanczossharp
cscale=ewa_lanczossharp
# Interpolation
video-sync=display-resample
interpolation
tscale=oversample
# Audio  
audio-channels=stereo
# Cache
cache=yes
cache-on-disk=yes
cache-dir=/mnt/ext4/mpv
# Protips https://github.com/thann/play-with-mpv
window-scale=0.4
geometry=100%:100%
#keep-open
1 Like

And far less private watching any video content in a browser.

indeed, no cookies or browse history to worry about, and also, no ads…

I used to use ff2mpv. Not anymore. It’s far easier ( for me ) to F12 ( yakuake or some other dropdown terminal) then mpv and URL. Done. Nothing external, no services running no scripts. Simpler and cleaner. Again I repeat for me. Everyone is different. And Linux can accommodate all. Best thing about it.

1 Like