mpv
mpv copied to clipboard
Generate list of supported protocols in desktop-file dynamically
Important Information
- mpv 0.33.1
- Arch Linux (up-to-date), binary from community repo
Reproduction steps
- In Dolphin, under Arch Linux, navigate to a folder on a SMB-share containing multimedia files.
- Open any video/audio file with mpv
- mpv fails with error:
[ffmpeg] Protocol not found. Make sure ffmpeg/Libav is compiled with networking support. Failed to open smb://@server.local:445/Videos/example.mkv.
Expected behavior
Dolphin should have more accurate information about supported protocols and pass a file://
URL instead if a given protocol, e.g. smb, isn't supported in a given environment.
Actual behavior
mpv
s .desktop-file currently statically enumerates all protocols it expects to support in X-KDE-Protocols
. Since 0.33, when libsmb-support was dropped with reference to ffmpeg-support, opening files on a smb-share broke in KDE environments on Arch, which compiles ffmpeg without libsmb-support (and won't, see https://bugs.archlinux.org/task/69798). Dolphin trusts the listed protocols though to decide whether to pass a protocol-URL directly or transparently fuse-mount via kio-fuse before.
If that is possible, can the list of support protocols be generated at compile time by querying the ffmpeg being linked against about its supported protocols?
Log file
If that is possible, can the list of support protocols be generated at compile time by querying the ffmpeg being linked against about its supported protocols?
Even simpler, the compiled mpv can be run to get this information, including mpv-supported protocols in addition to just the ffmpeg ones: mpv --list-protocols | grep '://' | sed 's/^ *//g'
I guess that just means there's some build system wrangling left to do to generate the .desktop file from that.
EDIT: apparently we can't do it that simply because of cross-compilation, which sucks
EDIT: apparently we can't do it that simply because of cross-compilation, which sucks
Meaning it would be unreasonably difficult to implement or just that it takes more thought?
Meaning it would be unreasonably difficult to implement or just that it takes more thought?
It means there needs to be some fallback in place, which is okay to do. The protocols mpv supports are pretty much queried at runtime as far as I know, as some are dynamically loaded from the ffmpeg libraries. So we can't do it statically without running the mpv binary.
I've attempted to write a autodetect-with-fallback solution but I can't coerce waf into running that code after the mpv binary has been built to generate a .desktop file, so I'll leave it to someone more knowledgeable with the build system to look into it.
If anyone's hurting for an easy workaround on Arch, you can make a copy of /usr/share/applications/mpv.desktop
to ~/.local/share/applications
and remove the X-KDE-Protocols
line. This will override the package-installed shortcut and make mpv use kio-fuse.
Actually we have meson now which should make this easier to do. Wouldn't be impossible on waf, but probably would be more painful. I might try it out later.
If anyone's hurting for an easy workaround on Arch, you can make a copy of /usr/share/applications/mpv.desktop to ~/.local/share/applications and remove the X-KDE-Protocols line. This will override the package-installed shortcut and make mpv use kio-fuse.
does this workaround still work? it does not work for me.
Yes it works for me. Instead of removing the entire line I just removed smb from the list.
@urbenlegend thanks for the comment! Here are the commands to do this automatically. This needs to be run every time mpv gets updated:
cp /usr/share/applications/mpv.desktop ~/.local/share/applications/
sed -i '/^X-KDE-Protocols/s/,smb//; /^X-KDE-Protocols/s/smb,//; /^X-KDE-Protocols/s/smb//; /^X-KDE-Protocols=$/d' ~/.local/share/applications/mpv.desktop
If your package manager supports hooks then it might be a good idea to have it run after mpv is upgraded, until this is fixed. Example for Arch pacman:
/etc/pacman.d/hooks/mpv-fix.hook
[Trigger]
Operation = Upgrade
Type = Package
Target = mpv
[Action]
Description = Fixing mpv desktop file for KDE Plasma integration...
When = PostTransaction
Exec = /etc/pacman.d/hooks/mpv-fix.sh