ff2mpv icon indicating copy to clipboard operation
ff2mpv copied to clipboard

Option for piping the video out via yt-dlp to mpv:

Open tharrisone opened this issue 2 years ago • 6 comments

There are some serious caching issues in mpv due to ffmpeg. I've gone over every cache setting in mpv and found only minimum changes no matter what.

I'd like an option to play the video via yt-dlp and piping it out to mpv. I made a very simple alias myself for the terminal and it uses my bandwidth properly and caches the whole video in seconds.

play() { yt-dlp -o - "$1" | mpv - }

I have been using mpv for many years but only recently started watching youtube/invidious videos through ff2mpv which is great. Also it would be helpful to make the firefox users aware that you need to download your scripts. I didn't know I needed to do that until I went to your home page from the addon page.

tharrisone avatar Apr 27 '22 01:04 tharrisone

Also it would be helpful to make the firefox users aware that you need to download your scripts. I didn't know I needed to do that until I went to your home page from the addon page.

Where else do you think we should advertise that the native client is needed? It's currently displayed prominently in the README on AMO:

Screen Shot 2022-04-26 at 9 58 54 PM

(That's not a rhetorical question! If you know other places we should mention it, please let us know!)

woodruffw avatar Apr 27 '22 04:04 woodruffw

Re: the original issue topic: yes, this is something that's frustrating about how MPV has chosen to implement their youtube-dl/yt-dlp support.

I can think of a few potential options for us:

  1. Do nothing, and hope it gets better over time. This would be compatible with our general policy of not duplicating or patching over MPV or youtube-dl's behavior, but this is a case where the default behavior is pretty bad and unconfigurable.
  2. Change the native clients to do piping by default. This will have the intended effect, but it also complicates the native clients and introduces assumptions about which youtube-dl/yt-dlp program the user has installed (and whether we can execute it, versus merely being able to exec MPV).
  3. Show users how to patch their own native clients locally.
  4. Something else?

woodruffw avatar Apr 27 '22 05:04 woodruffw

Changing the native client does complicate things, and showing users how to patch the client would keep things as they are and offer an option for some people. Btw.. I don't know how I missed that link to your native client.

tharrisone avatar Apr 27 '22 15:04 tharrisone

I have to thank you for the nice tip @tharrisone. I've been looking for a way to cache things faster in mpv.

@woodruffw Here is an idea:

  • Add a shim file to call the client. This shim file can be updated with the install script, so it can add a flag for the native client (something like -p for pipe or similar).
  • Use this flag in the client to alter the behavior. If present it will do the piping call, else work as usual.

Based on my knowledge of the python client it could be implemented by abstracting both ways to call mpv into separate functions and call them accordingly. Although I don't know how much complexity is to call a pipe process in python. A quick search shows this. I don't know anything about ruby, so I can't say much about the ruby client.

DanSM-5 avatar Apr 30 '22 21:04 DanSM-5

play() { yt-dlp -o - "$1" | mpv - }

This unfortunately streams only 720p version of videos. Can't stream video only + audio only ones that are off high quality... Edit: I had to do yt-dlp -f bestvideo+bestaudio/best -o - '$1' | mpv - to make it work. But still, the mpv slider is dynamically increasing while watching, which gives issue where I can't fast forward like in the middle of the video.

ghost avatar Jul 22 '22 01:07 ghost

Just to make sure everybody knows: if you know what you're doing and know what you want, it's perfectly fine to patch the native client on your own machine!

We try very hard not to break the native client between releases (and will never do so without new major version), so you can generally assume that you won't need to re-patch it whenever the browser-side extension updates.

woodruffw avatar Jul 22 '22 03:07 woodruffw

Hello, i don"t know many things about computers and codes.... but may be this tool can help to avoid bugs, i see in wiki : " The Ruby native client does not work on Windows. You'll need to use the Python native client, which is included in the steps below and all helper scripts."

so I find this revolutionary framework PyScript that allows users to create rich Python applications in the browser using HTML's interface and the power of Pyodide, WASM, and modern web technologies. PyScript is a meta project that aims to combine multiple open technologies into a framework that allows users to create sophisticated browser applications with Python.....

https://github.com/pyscript/pyscript

trimechee avatar Oct 20 '22 10:10 trimechee

Thanks for the information, but this probably won't help our use case at all: the context in which we use Python has nothing to do with the browser itself.

woodruffw avatar Oct 20 '22 16:10 woodruffw

Interesting :) in any case thank you very much for all your efforts to develop this very useful and wonderful software 🥇

trimechee avatar Oct 20 '22 17:10 trimechee