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

mpv via yt-dlp very slowly caching videos from youtube and other services, but pure yt-dlp downloading very fast. #12254

Closed
ghost opened this issue Aug 26, 2023 · 7 comments

Comments

@ghost
Copy link

ghost commented Aug 26, 2023

Important Information

mpv 0.36.0+git.20230730.1bbc7a2c Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
built on Jul 31 2023
libplacebo version: v6.292.1
FFmpeg version: 6.0
FFmpeg library versions:
libavutil 58.2.100
libavcodec 60.3.100
libavformat 60.3.100
libswscale 7.1.100
libavfilter 9.3.100
libswresample 4.10.100
openSUSE Tumbleweed
https://build.opensuse.org/package/show/multimedia:apps/mpv

Reproduction steps

~/.mpv/config

hwdec=none
fs=yes
ytdl-format=bestvideo[height<=1080][fps<=?60][vcodec^=?avc]+bestaudio/best[height<=1080][fps<=?60][vcodec^=?avc]

The --no-config option has no effect on repeatability.
run mpv with any 1080p60 video (-f299+251), for example mpv -f299+251 https://www.youtube.com/watch?v=dkihNga60tw
Wait for 5-10 minutes of playback and observe the cached time.

Expected behavior

The caching time should be constantly increasing, possibly up to a certain high limit. This has always been the case in the past.

Actual behavior

For the first 5 minutes the caching works as it should, then it slows down a lot and then quickly depletes to zero and the caching speed is not enough for comfortable viewing.

Log file

mpv-log.txt

Additional information

I can assume that mpv has nothing to do with it and it's either yt-dlp or youtube or my internet provider.
It's easy to check.
yt-dlp -f'bestvideo[height<=1080][fps<=?60][vcodec^=?avc]+bestaudio/best[height<=1080][fps<=?60][vcodec^=?avc]' https://www.youtube.com/watch?v=dkihNga60tw

[youtube] Extracting URL: https://www.youtube.com/watch?v=dkihNga60tw
[youtube] dkihNga60tw: Downloading webpage
[youtube] dkihNga60tw: Downloading ios player API JSON
[youtube] dkihNga60tw: Downloading android player API JSON
[youtube] dkihNga60tw: Downloading m3u8 information
[info] dkihNga60tw: Downloading 1 format(s): 299+251
[download] Destination: Indiana Jones and the Temple of Doom (NES) [dkihNga60tw].f299.mp4
[download] 100% of    5.25GiB in 00:09:56 at 9.01MiB/s
[download] Destination: Indiana Jones and the Temple of Doom (NES) [dkihNga60tw].f251.webm
[download] 100% of  174.25MiB in 00:00:18 at 9.18MiB/s
[Merger] Merging formats into "Indiana Jones and the Temple of Doom (NES) [dkihNga60tw].mkv"

5.25GiB in 00:09:56 at 9.01MiB/s
I have a 100 MB connection and the average speed is close to the maximum connection speed.
So neither yt-dlp nor youtube nor my provider restricts access to youtube and other video services.
From this I conclude that something is wrong with mpv.
I started to notice such behavior about a month ago, before that it did not happen.

@llyyr
Copy link
Contributor

llyyr commented Aug 26, 2023

Does --ytdl-raw-options=format-sort="proto:m3u8" help?

@ghost
Copy link
Author

ghost commented Aug 26, 2023

Does --ytdl-raw-options=format-sort="proto:m3u8" help?

No, unfortunately, this option has no effect on repeatability.

@sfan5
Copy link
Member

sfan5 commented Aug 26, 2023

duplicate/cantfix, see #8655 (comment)

@ghost
Copy link
Author

ghost commented Aug 26, 2023

I have a problem not only with youtube, but also with other video services.
Download and launch is not applicable to streaming and live broadcasts.
Why can't caching be hung on yt-dlp or make its own layer for that before ffmpeg?
Does the ffmpeg upstream know about the problem?

I realize that this sounds definitely not like an ffmpeg problem, since ffmpeg's job is encoding and decoding, not splitting requests into pieces to bypass video service limitations.
Maybe there is a layer in ffmpeg to take over the downloading, leaving ffmpeg only decoding?

@ghost
Copy link
Author

ghost commented Aug 26, 2023

P.S. I don't agree with closing this problem as the problem in mpv is not solved.
The problem is solved in yt-dlp, but mpv doesn't use that loading mechanism.
This is clearly not ffmpeg's problem, as its job is to decode, which it handles.
If ffmpeg's problem is that it is taking on a task that is not its own and does not provide an interface to implement this functionality on its own, then this problem should be reported to ffmpeg.

@ghost
Copy link
Author

ghost commented Aug 29, 2023

That's such a crutch...

u="video_url" && n="`yt-dlp -Otitle $u`" && f="/tmp/$n" && yt-dlp --max-filesize 1.8G --sub-langs 'en,ru' --embed-subs --embed-chapters --no-part -f'bestvideo[height<=1080][fps<=?60][vcodec^=?avc]+bestaudio/best[height<=1080][fps<=?60][vcodec^=?avc]' -o"$f" "$u" && mpv --slang=ru "$f"* && rm "$f"*

But in any case for streaming broadcasts neither this option nor the option with separate audio stream loading is not suitable and mpv should load via yt-dlp instead of ffmpeg itself by default!

@Arc-2023
Copy link

also meeting the same problem,while i think tring use code like these help with a cracked aria2c.exe:

ytdl-raw-options-append=external-downloader=aria2c
ytdl-raw-options-append=downloader-args=aria2c:"-x 256 -k 128k"

But it doesn't.

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

No branches or pull requests

3 participants