-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Super high traffic usage when playing specific YouTube live stream #14360
Comments
Use --ytdl-format. Default downloads the highest quality formats. |
@po5 Even playing lowest resolution video (144p) downloads about 3MB per second. |
What is the problem exactly? I smell XY here... Depending on your mpv cache options it will cache/download data as fast as possible, until the cache is filled. It won't download more data than is needed for the playback, it will do it faster and stop the transfer quicker. |
@kasper93 No, this is mpv problem. Please read my report carefully. I beleave you can test on your side. |
You may not have noticed that is a live stream, so mpv starts playing from the current time. |
You simply cannot take current average speed per second and extrapolate it to whatever duration you want. Note that resource monitor averages the values too. Download https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer double click on mpv.exe and observe network tab. It will show you cumulative data received. |
@kasper93 I checked with procexp and saw the Receive Bytes increasing at a similar rate order (about 250MB per minute). |
Feel free to report it to ffmpeg if there is a problem there, mpv doesn't control downloading rate/data. |
@kasper93 yt-dlp also utilizes ffmpeg, but it downloads in a reasonable rate. I noticed that Maybe mpv loads the stream from the past 1 hour? How to let mpv to load the stream from current time? |
yt-dlp only uses ffmpeg for muxing, not for networking. mpv uses ffmpeg for networking, and the issue is also reproducible with ffplay, so it's ffmpeg's HLS stream handling at fault. (Side note: ffmpeg is bad at stream handling in general, especially HLS, and there are various bugs associated with it. VLC handles the link in the OP correctly without high traffic usage because it uses its own network layer. IMO mpv should also do the same, but for now you have to report the issue to ffmpeg.) |
Comparing both .m3u8 URLs, I noticed that mpv's URL has Seeing the output of Why don't you make this behavior default? Is this still ffmpeg's problem?? Anyway, this problem has been solved on my end. |
Well, when playing other streams, there is no problem about download rate even when .m3u8 URL contains |
There is no reason why ffmpeg can't handle the mentioned stream properly. |
I think we should keep this issue open for visibility.
Like already said by na-na-hi, only for muxing. It would indeed be nice to improve that. I will reopen in case anyone wants to work on the improvments, either in ffmpeg or directly in mpv. |
This is very interesting since similar behavior showed up in my own stream grabber.
Current HLS versions (might be still a draft) support DASH-style variable substitution, so this problem may go away in the future, but not anytime soon. |
I don't know why I didn't think of this yesterday, but here is a work-around:
This makes use of the fact that HLS playlists are highly-compressible. |
This should really be fixed on ffmpeg side or it cannot be used for modern content delivery services. It is known issue for years: https://trac.ffmpeg.org/ticket/7158 |
To be fair to ffmpeg, this is an unusual situation where the total duration of a live playlist is big, and the segment duration is small. A segment duration of 5 seconds would reduce the overhead by ~25x, since you would have 1/5x of the segments in the playlist, and you would need to update the playlist 1/5x as frequently. And a good client should allow controlling the frequency of playlist updates. In my stream grabber, I already have a let playlist_req_freq = ctx.config.playlist_req_freq;
let seg_avg_low_dur = (segs_dur / segs_count + min_seg_dur) / 2.0;
// playlist_req_freq=0.1 => delay = seg_avg_low_dur*5
// playlist_req_freq=0.5 => delay = seg_avg_low_dur
// playlist_req_freq=1.0 => delay = seg_avg_low_dur*0.5
let delay = seg_avg_low_dur / playlist_req_freq / 2.0;
let delay = delay
// in case the playlist is small (< 5 segments)
.min(seg_avg_low_dur*segs_count)
.max(1.0); I thought this was enough, but in this use-case, the least frequent update period would still be 5 seconds. Better can be done, with taking the number of segments in the playlist into account. As I already mentioned, variable substitution would help here too. So the problem may fix itself in X years 🥲. |
mpv Information
Other Information
Reproduction Steps
mpv https://www.youtube.com/watch?v=thYDM-UAMKg
Note: The stream lasts long but not permanent. In a few weeks, there may be no way to reproduce.
Expected Behavior
When played from a web browser e.g. chrome, its network usage is about 300KB per second (1080p).
![with chrome](https://private-user-images.githubusercontent.com/4504807/339957109-b8043e41-48e8-4cb7-89dd-663798bdb517.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk1NzIyOTAsIm5iZiI6MTcxOTU3MTk5MCwicGF0aCI6Ii80NTA0ODA3LzMzOTk1NzEwOS1iODA0M2U0MS00OGU4LTRjYjctODlkZC02NjM3OThiZGI1MTcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjhUMTA1MzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDY0ZDhiZTQ2MzkxNDk0NGZiNGJjY2U3NWIyZmY4NmUzNjhhMGRmZDA0NDFmNTc5MGYwODZlZjU3ZDFhY2JiZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.pl5yJjxU9c_9X-vRhm6j_SdeomT8XsaM4VXhSUwryFM)
Actual Behavior
The stream is played successfully, but mpv downloads over 6MB per second (not 6 megabits, it's 6 megabytes per second).
![with mpv](https://private-user-images.githubusercontent.com/4504807/339956889-d622a1c5-dad7-4f0b-a390-640625de66f8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk1NzIyOTAsIm5iZiI6MTcxOTU3MTk5MCwicGF0aCI6Ii80NTA0ODA3LzMzOTk1Njg4OS1kNjIyYTFjNS1kYWQ3LTRmMGItYTM5MC02NDA2MjVkZTY2ZjgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjhUMTA1MzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjhhOTY4MDBkOTJhOTA3MDdmNmE4MmU3Y2UxYjQ1NDM5NWI0MjNiM2ZmNjIxMmY3MTdhNzRjNzg2YzQ3YmEyZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.xiHCpabVplJghv36mOatnAXYiY5nq4EwKLyLEQnywd4)
As far as I've tested, other streams do not have similar problem.
Log File
output.txt
Sample Files
No response
I carefully read all instruction and confirm that I did the following:
--log-file=output.txt
.The text was updated successfully, but these errors were encountered: