mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Generate list of supported protocols in desktop-file dynamically

Open prettyv opened this issue 3 years ago • 8 comments

Important Information

  • mpv 0.33.1
  • Arch Linux (up-to-date), binary from community repo

Reproduction steps

  1. In Dolphin, under Arch Linux, navigate to a folder on a SMB-share containing multimedia files.
  2. Open any video/audio file with mpv
  3. 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

mpvs .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

mpv.log

prettyv avatar Apr 15 '21 16:04 prettyv

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

CounterPillow avatar Apr 15 '21 17:04 CounterPillow

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?

prettyv avatar Apr 16 '21 20:04 prettyv

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.

CounterPillow avatar Apr 17 '21 04:04 CounterPillow

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.

urbenlegend avatar May 04 '21 07:05 urbenlegend

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.

Dudemanguy avatar Jan 09 '23 21:01 Dudemanguy

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.

24fpsDaVinci avatar Nov 15 '23 00:11 24fpsDaVinci

Yes it works for me. Instead of removing the entire line I just removed smb from the list.

urbenlegend avatar Nov 15 '23 01:11 urbenlegend

@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

ericswpark avatar May 06 '24 01:05 ericswpark