woodruffw / ff2mpv

A Firefox/Chrome add-on for playing URLs in mpv.
https://addons.mozilla.org/en-US/firefox/addon/ff2mpv/
Other
492 stars 51 forks source link

Does not work on brave-browser #98

Closed beew closed 5 months ago

beew commented 1 year ago

When click the ff2mpv icon nothing happens

start brave from the terminal, go to Youtube and click the ff2mpv icon, got these error messages

mpv: symbol lookup error: mpv: undefined symbol: vkCreateXlibSurfaceKHR

OS is Ubuntu 22.04

Brave version 1.48.171 (based on Chromium 110.0.5481.177 )

mpv version

$ mpv
mpv 0.35.1 Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
 built on Tue Feb 28 04:54:15 2023
FFmpeg library versions:
   libavutil       58.2.100
   libavcodec      60.3.100
   libavformat     60.3.100
   libswscale      7.1.100
   libavfilter     9.3.100
   libswresample   4.10.100
FFmpeg version: 6.0-0ubuntu1~22.04.sav0

addition info

1) mpv works on local video, streaming through command line and ff2mpv works on firefox.

2) I have disabled brave's adblocker and re-eanbled it. Still doesn't work

3) this mpv addon does work for brave https://chrome.google.com/webstore/detail/play-with-mpv/hahklcmnfgffdlchjigehabfbiigleji

woodruffw commented 1 year ago

Thanks for the report! Which native client are you using, and are you using any special arguments / MPV profiles with it?

beew commented 1 year ago

Hi, thanks for the reply.

I am not sure what you meant by native client. It is pretty much stock brave-browser.

My mpv config is pretty basic

vo=gpu 
hwdec=vaapi

volume-max=120 
ao=pulse

ytdl-format=bestvideo[height<=?1080][vcodec!*=av01]+bestaudio/best
beew commented 1 year ago

Hi,

I found out the reason that it wasn't working is that chromium based browsers include their own libvulkan which is broken. https://www.reddit.com/r/mpv/comments/ry9sgi/i_keep_getting_this_error_when_opening_mpv_on/

It is not clear from that thread why running mpv would invoke chrome's libvulkan (in my case mpv works fine except through brave with ff2mpv), but the error message is the same.

I fixed it with a wrapper script for mpv like in one of the anwers

#!/bin/bash

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libvulkan.so.1

/usr/bin/mpv "$@"

Now ff2mpv works for both brave and firefox.

Instead of using the wrapper, can this be done by editing ff2mpv.py?

woodruffw commented 1 year ago

Thanks for root-causing. My guess there is that the mpv process inherits its runtime environment from a browser worker/extension management process, which means that we end up with whatever that environment specifies for load order.

I am not sure what you meant by native client.

The native client is the thing named either ff2mpv.py or ff2mpv that the extension executes to actually spawn mpv. It's installed by the installer script.

So yes, this can be done by editing ff2mpv.py. I'd suggest documenting any changes you make on the community-maintained ff2mpv wiki :slightly_smiling_face:

sudoshindo commented 6 months ago

Same issue with Brave on Fedora 39.

@beew How do I make this wrapper script work and where do I put it?

Both this and Thann/play-with-mpv are broken. What an absolutely horrible time this is.

beew commented 6 months ago

Same issue with Brave on Fedora 39.

@beew How do I make this wrapper script work and where do I put it?

Both this and Thann/play-with-mpv are broken. What an absolutely horrible time this is.

Hi,

I posted the script above.

Name it mpv, make it executable and place it in a directory in your $PATH that overrides /usr/bin. This way when you invoke mpv say by typing mpv in the terminal it runs the script instead of /usr/bin/mpv

In Ubuntu you can put the script in either ~/bin or ~/.local/bin. I am not sure about Fedora, you may need to add the path to your .profile or .bashrc then logout and login if it is not already there. /usr/local/bin is fine too but that needs sudo and I think Fedora doesn't respect /usr/local.

my .profile looks like this


if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

See "set Path so it includes user's private bin if exists". If they don't exist create them then logout and login for it to take effect

sudoshindo commented 6 months ago

I found a way to make the other extension work (Thann/play-with-mpv) but thanks anyway.

beew commented 6 months ago

I found a way to make the other extension work (Thann/play-with-mpv) but thanks anyway.

I used to use that one but I switched because it spawned some zombie processes after playing the video. Check with top.

woodruffw commented 5 months ago

This is an independent manifestation of #109. It looks like both Chrome-type browsers and Firefox have this problem, albeit with different interfering libraries.

I have no good ideas for a fix here, other than doing some additional process isolation when spawning mpv (maybe we could further filter the parent's environment)?

woodruffw commented 5 months ago

Closing in favor of continued tracking on #109.

beew commented 5 months ago

This is an independent manifestation of #109. It looks like both Chrome-type browsers and Firefox have this problem, albeit with different interfering libraries.

I have no good ideas for a fix here, other than doing some additional process isolation when spawning mpv (maybe we could further filter the parent's environment)?

I have no problem with Firefox. But I grabbed firefox from Mozilla (tarball) to avoid snap. Not sure how they installed it.

woodruffw commented 5 months ago

I have no problem with Firefox. But I grabbed firefox from Mozilla (tarball) to avoid snap. Not sure how they installed it.

Yeah, I suspect that this is some of the problem. I also avoid the snap-ified Firefox and haven't had problems.

sun95n commented 5 months ago

Instead of using the wrapper, can this be done by editing ff2mpv.py?

Yes, just add it as an argument, something like:

args = ["env", "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libvulkan.so.1", "mpv", url]