mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.96k stars 2.88k forks source link

mpv + ytdl --no-video caches whole audio file before playing #2359

Closed marnunez closed 8 years ago

marnunez commented 8 years ago

That's pretty much it. Without the --no-video flag, the video plays instantly. With it, I get [cache] Cache is not responding - slow/stuck network connection? several times, and, for example, A: 00:00:25 / 00:04:01 (10%) Cache: 10s+6MB

My command line example: mpv --ytdl --autofit 300 --geometry=0%:100% --no-border --ontop --load-unsafe-playlists --volume=50 "URL" --no-video

Using latest youtube-dl (2015.09.28), Win XP SP2 (don't even get me started :angry:)

mpv 0.11.0-git-f8c5743 (C) 2000-2015 mpv/MPlayer/mplayer2 projects built on Wed Sep 23 01:58:01 CEST 2015 ffmpeg library versions: libavutil 55.2.100 libavcodec 57.3.100 libavformat 57.2.100 libswscale 4.0.100 libavfilter 6.8.100 libswresample 2.0.100 ffmpeg version: N-75488-g44e38f5

ghost commented 8 years ago

Requires a sample URL.

marnunez commented 8 years ago

I've just tried with this one, for example. mpv --ytdl --autofit 300 --geometry=0%:100% --no-border --ontop --load-unsafe-playlists --volume=50 --no-video "https://www.youtube.com/watch?&list=RDqQrgto184Tk#t=0"

ghost commented 8 years ago

I think this happens because the ytdl script forces bestaudio/best as format if video is explicitly disabled (the ytdl script explicitly queries the player options for this). And it also doesn't allow the user to override the format.

The actual bad behavior comes from the fact that Youtube serves a DASH-style mp4 file, which ffmpeg's mp4 demuxer doesn't handle correctly.

CC @ChrisK2 - should we remove this hack from ytdl?

ChrisK2 commented 8 years ago

I don't use it, but I still think the hack makes sense for saving bandwidth, like it would here as well.

As a workaround, just add the option --ytdl-format=251/171/bestaudio to use the 'free' webm formats whenever available, those should not have the problem of requiring to preload the whole file.

ghost commented 8 years ago

As a workaround, just add the option --ytdl-format=251,171,bestaudio

Except this does nothing, because the script still overwrites the format.

ChrisK2 commented 8 years ago

oh ... shit. Well, fixed as of 1b7e8ff6c590ef3ef289c7468941acd6cf450e41.

I also corrected the custom format, used wrong syntax. Should work as intended now.

marnunez commented 8 years ago

Thanks! As soon as I get home I'll compile and test. This being a workaround, what would a proper fix be? Fix the DASH mp4 demuxing in ffmpeg?

ChrisK2 commented 8 years ago

Ideally yes.

marnunez commented 8 years ago

Superb!