Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tharrisone opened this issue Apr 27, 2022 · 9 comments
Closed

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

tharrisone opened this issue Apr 27, 2022 · 9 comments

Comments

@tharrisone
Copy link

tharrisone commented Apr 27, 2022

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Contributor

DanSM-5 commented Apr 30, 2022

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.

@ghost
Copy link

ghost commented Jul 22, 2022

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
Copy link
Owner

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
Copy link

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
Copy link
Owner

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants