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

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

Closed tharrisone closed 1 year ago

tharrisone commented 2 years ago

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.

woodruffw commented 2 years ago

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 commented 2 years ago

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?
tharrisone commented 2 years ago

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.

DanSM-5 commented 2 years ago

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:

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.

ghost commented 1 year ago

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.

woodruffw commented 1 year ago

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.

trimechee commented 1 year ago

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

woodruffw commented 1 year ago

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.

trimechee commented 1 year ago

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