pipe-viewer icon indicating copy to clipboard operation
pipe-viewer copied to clipboard

[Question] How to increase mpv download speed with pipe viewer?

Open sun95n opened this issue 2 years ago • 5 comments

So YouTube video and audio download speed is limited by ffmpeg as mentioned in this thread. Although I understand that pipe-viewer manages both URLs separately. So the logical thing to do would be to pass the URL to mpv to make it work. The problem is that mpv takes 5-7 seconds to parse a URL unlike pipe-viewer which only takes 2. So is there any other method to achieve this?

sun95n avatar Dec 11 '22 07:12 sun95n

I didn't think I would find a solution for this, haha. It was enough to set split_videos to 0 to avoid the download limits. Although you will only be able to view videos with 720p and 360p resolution, 1080p or higher will revert to 720p

@trizen do you think you can explain why this behavior happens? According to the documentation:

https://github.com/trizen/pipe-viewer/blob/25c176b3f3210ff970cbbdddac476b606c66690d/bin/pipe-viewer#L5075-L5077

Although I would appreciate if it would be easier to explain in this context.

sun95n avatar Dec 29 '22 01:12 sun95n

Thanks a lot. I guess now I can close it.

sun95n avatar Dec 29 '22 05:12 sun95n

@trizen YouTube has now limited the resolution to 360p for split videos :(

mpv users have proposed a couple more solutions to this problem, however, Guidocella's comment continues to be the most voted.

Selecting HLS streams with --ytdl-format='bestvideo[protocol^=m3u8]+bestaudio[protocol^=m3u8]/bestvideo+bestaudio/best' reduces the throttling, but it breaks seeking to timestamps that haven't been cached in >= 1440p streams, and doesn't select 4320p streams.

You can also let yt-dlp do the downloading by piping its standard output to mpv, e.g. with this zsh script:

Is there a way to implement this within Pipe Viewer? It worked for me.

sun95n avatar Jul 05 '24 22:07 sun95n

YouTube has now limited the resolution to 360p for split videos :(

There is no more 720p

https://github.com/trizen/pipe-viewer/blob/6f692afe25530d6568e8763c3d468224ee131afd/bin/pipe-viewer#L5137-L5141

sun95n avatar Jul 05 '24 23:07 sun95n

The solution proposed in Guidocella's comment, using yt-dlp for downloading the streams and piping its standard output to mpv, is very nice and clever.

We can use it in pipe-viewer, by adding a new player entry:

 ytdlp_pipe => {
   arg => "--force-media-title=*TITLE* --audio-file=<(yt-dlp --http-chunk-size 10M -o - *AOV*) <(yt-dlp --http-chunk-size 10M -o - *VIDEO*)",
   cmd => "mpv",
   fs => "--fullscreen",
   novideo => "--no-video",
   srt => "--sub-file=*SUB*",
 },

and setting:

video_player_selected => "ytdlp_pipe",

or executing:

pipe-viewer --player=ytdlp_pipe

The other solution proposed, can be added as:

 ytdlp_hls => {
     arg => "*URL* --ytdl-format='bestvideo[protocol^=m3u8]+bestaudio[protocol^=m3u8]/bestvideo+bestaudio/best'",
     cmd => "mpv",
     fs => "--fullscreen",
     novideo => "--no-video",
     srt => "--sub-file=*SUB*",
 },

trizen avatar Aug 06 '24 21:08 trizen

The second method worked for me. Thank you so much! :D

sun95n avatar Oct 02 '24 22:10 sun95n