Customization tricks - woodruffw/ff2mpv GitHub Wiki

How to just play audio in mpv with GUI

Some times you just want to listen to the audio of a video and conveniently there --no-video flag on your ff2mpv.py saving some bandwidth and other resources. But (if using the addon function) there is no way to control the volume and other properties of the video, this can be solved with --force-windows=yes flag to display the mpv client. In your ff2mpv.py or ff2mpv:

args = ["mpv", "--force-windows=yes", "--no-video", url]

The --profile argument

These flags can be put in a profile too in your mpv.conf (as all your flags can). The appended lines would look like this:

[music]
no-video
force-windows=yes

The name "music" can be "potato" if you want, this is just a variable.

Then in your native client:

args = ["mpv", "--profile=music", url]

Adding subtitles to videos

Similar to the above, you can add subtitles with a custom profile:

[subs]
slang=en,eng,english
sub-auto=fuzzy
ytdl-raw-options=ignore-config=,sub-lang="en.*",write-sub=,write-auto-sub=

...in this case, you'd patch your native client like so:

args = ["mpv", "--profile=subs", url]

Custom URL behavior

Depending on how you use ff2mpv and mpv, you may find that you need to add custom behavior for certain domains and URL patterns. For example, you might want to:

  • Add HTTP Basic credentials to a URL
  • Transform a URL to match your locality

For simplicity's sake, ff2mpv does not support URL modification within the add-on itself, and probably never will.

However, with a little bit of Ruby (or Python), you can accomplish the same thing within the native client: just test the url variable against whatever conditions you require.

For example, here's how you could add some sort of authentication to a URL whose host is example.com with the Ruby native client:

if URI(url).hostname == "example.com"
  url = add_auth url
end

Note, however, that url is not guaranteed to be a well-formatted URI -- it can be anything selected by the user in the browser.

Setting profiles (context menu entries)

You can add additional context menu entries that can send custom flags to the client by adding a profile. A profile consists on a name that will be displayed in the context menu entry and text that will be passed as arguments to mpv.

[!WARNING]
Only the python and ruby clients have support for profiles by reading the options array. If you are using a compiled client, you'll need to read the options as well.

See python implementation as an example.

Adding a profile

[!WARNING] Only add profiles that you trust! Arbitrary MPV flags should be considered arbitrary code, and should be reviewed carefully.

See mpv manual

  1. In your browser go to manage extensions.
  2. Locate ff2mpv and click it to go to its details.
  3. Locate extension options and click on it.
  4. Click on the Add button.
  5. Add a name to the profile. As an example, lets add a Youtube 720p profile name.
  6. Add the arguments that will be send to mpv. Set 1 argument per line. You may need to quote/escape the argument. ff2mpv will send the arguments as you type them. For our example let's add --ytdl-format=bestvideo[height<=720][vcodec!=vp9]+bestaudio/best.
  7. When you are done click on the save button in the profile.

The profile should look like this.

image

You can remove the profile by clicking on the delete button.

[!IMPORTANT]
If you add a profile, the context menu in ff2mpv will change. Instead of being a single button, you will have a sub menu with the default Play in MPV option and one option per each profile that you add.

[!WARNING]
Sending invalid flags/options or wrongly formatted strings will cause mpv to not start. Please do not report bugs if a profile you added is not working. You will need to debug the issue yourself.