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

Change default value of --ytdl-format to include DASH #1321

Closed
haasn opened this issue Dec 7, 2014 · 19 comments
Closed

Change default value of --ytdl-format to include DASH #1321

haasn opened this issue Dec 7, 2014 · 19 comments

Comments

@haasn
Copy link
Member

haasn commented Dec 7, 2014

I would like to suggest switching the default value of --ytdl-format from what we use currently (nothing, which falls back to youtube-dl's default of “best” - which might be worth documenting, incidentally) to the value “bestvideo+bestaudio/best”.

The reason youtube-dl ignores stuff like DASH by default is because it's a tool designed to download the files, and using bestvideo+bestaudio forces it to download first the entire video, then the entire audio, then mux them together using ffmpeg. This problem does not apply to us since we just directly stream either way.

The difference this would make is that it would effectively enable DASH video/audio for youtube, giving casual users of mpv easy access to 1080p videos by default, which would be an actual serious advantage over quvi.

The drawbacks are that DASH support is currently suboptimal w.r.t duration due to bugs in ffmpeg, so I would expect at least a quick client-side workaround that lets us display, if nothing else, an accurate progress bar on the OSD.

Whether this specific proposal gets granted or denied, it would be a good idea to add more documentation about this parameter. For example, it doesn't mention the special formats “bestvideo” and “bestaudio” (which will include DASH formats), nor the operator “a+b” for effectively playing two streams at the same time, nor the operator “/” for falling back to different versions.

@haasn haasn changed the title Default value of --ytdl-format Change default value of --ytdl-format to include DASH Dec 7, 2014
@ChrisK2
Copy link
Member

ChrisK2 commented Dec 7, 2014

First of all, I think that sticking with nothing -> best (= 720p) is the best solution, as it provides a good middle-ground between quality and required bandwidth for youtube which should work well for most people. Keep in mind that bestvideo is not limited to 1080p, but may get you up to 4K or 60fps when available which may cause problems for some users.

Secondly, as you already mentioned, DASH support should be considered only experimental at this point, and even if we fake the duration for display purposes, stuff like seeking remains broken (very slow). So I'm completely against using DASH formats by default unless DASH can be properly handled.

Thirdly, yes, the documentation could be improved a bit, I'll look into that.

ChrisK2 added a commit that referenced this issue Dec 7, 2014
@Zehkul
Copy link

Zehkul commented Dec 7, 2014

Also: While you might want to get 1080p via DASH, you certainly still want the normal 720p (or 360p respectively) video which is still available on youtube, not 720p DASH, as at least right now that would be a straight downgrade.

@ghost ghost added the meta:feature-request label Dec 12, 2014
@wiiaboo
Copy link
Member

wiiaboo commented Jan 4, 2015

Would be cool to be able to set --max-quality at mpv's config or lua-settings/ytdl-hook.conf and keep youtube-dl.conf with the --max-quality appropriate for downloads.

As I have limited bandwidth, I can barely handle 1080p30 streamed, but I like watching some gameplay at 1080p60 if available so I set youtube-dl.conf with "--max-quality 137" and whenever I want to download something to watch later, I use "--max-quality 299" as arg so I get 1080p60 to watch at leisure.

@ChrisK2
Copy link
Member

ChrisK2 commented Jan 4, 2015

Just put ytdl-format=137/best in your mpv.conf

@haasn
Copy link
Member Author

haasn commented Jan 4, 2015

Wouldn't that need to be 137+bestaudio/best? Also, that's not fully the same thing as --max-quality, because this wouldn't pick up 720p60 for instance.

@wiiaboo
Copy link
Member

wiiaboo commented Jan 4, 2015

Like with this video, for example.

@hyperknot
Copy link

A couple of points:

  • For a strange reason video inside 22 is higher quality version then 136
  Duration: 00:04:13.92, start: 0.033000, bitrate: 1934 kb/s
    Stream #0:0(und): Video: h264 (Main), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)

vs.

  Duration: 00:04:13.89, start: 0.000000, bitrate: 2675 kb/s
    Stream #0:0(und): Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
youtube_dash_video_formats="138/266/264/137/136/22/135/134/133"
youtube_dash_audio_formats="141/172/140/171/139"
  • I guess 298 should be inserted between 137 and 136 for 720p/60.
  • I guess there is no point of downloading a higher quality stream then the display's resolution, so the best possible solution would be to limit youtube_dash_video_formats to start with the current resolution's format (like 137 for FullHD displays).

@wiiaboo
Copy link
Member

wiiaboo commented Jan 9, 2015

I personally went with using

-f 299+bestaudio/137+bestaudio/298+bestaudio/22/135+bestaudio/18/best

on youtube-dl.conf (for downloads) and

ytdl-format=137+bestaudio/298+bestaudio/22/135+bestaudio/18/best

on mpv/config

@hyperknot
Copy link

Here is a list of all youtube-dl formats:
https:/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py

So far I believe this is the most complete list of video formats in descending resolution order:
"138/266/264/299/137/298/22/136/135/134/133"

@rrooij
Copy link
Contributor

rrooij commented May 10, 2015

Isn't DASH enabled by default now in youtube-dl with 'best' as format?

@wiiaboo
Copy link
Member

wiiaboo commented May 10, 2015

youtube-dl changed defaults to "bestvideo+bestaudio/best". Since mp4 dash videos still aren't fully supported, the defaults in mpv were changed to just "best".

@ghost ghost added the down-upstream:ffmpeg label May 10, 2015
@ghost
Copy link

ghost commented May 10, 2015

At least the ffmpeg mp4 demuxer needs to be fixed before we can do this.

@ghost ghost added the priority:stalled label Jul 18, 2015
@ghost
Copy link

ghost commented Dec 4, 2016

Nonono. Don't specify YouTube format codec numbers individually! I'm writing here because this post is the highest Google result for "mpv youtube 720p", and all of the methods above are terrible.

This is a more advanced way: It picks the best format it can find (up to but not above 1080p), chooses 30fps or lower (since 60fps just leads to dropped frames and stutter on my computer), and lastly it also ignores the stupid VP9 codec.

ytdl-format=bestvideo[height<=?1080][fps<=?30][vcodec!=?vp9]+bestaudio/best

If you want to limit it to 720p30 or lower, use this instead:

ytdl-format=bestvideo[height<=?720][fps<=?30][vcodec!=?vp9]+bestaudio/best

No matter what you do, I highly recommend using one of these lines in your mpv.conf. Otherwise it always picks the highest-quality version, which may mean 4K @ 60 fps = hell for your CPU to decode, and a total waste of bandwidth!

@tp0
Copy link

tp0 commented Dec 4, 2016

That's a pretty good config for most people, except for that fps part (you have to pretty old computer or your GPU acceleration isn't working properly if you can't play 60 fps even in H264?).

Also, at least for me H264 is automatically preferred, so that [vcodec!=vp9] is not needed. Or then it depends on GPU features.

For live videos, 60 fps isn't supported by youtube-dl and Youtube itself doesn't support higher than 1080p for live streaming.

@ghost
Copy link

ghost commented Dec 5, 2016

@tp0 Yeah I run with software-based CPU decoding on a 6-year old Core i7, where 60 fps @ 1080p leads to dropped frames and stutter. I could use GPU decoding but then I'd miss out on many mpv filters.

Many people with older computers would want the fps options. Others would want to remove it. Just take out the [fps<=?30] part.

As for H264 being preferred by default: Nope. Look at https:/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py (search for the word "vp9"). The "preference" strength of vp9 and h264 is identical, so it might possibly pick a vp9 stream if one is listed earlier in the metadata for a video. I don't know if they've got any more code to prefer h264 over vp9 in there, but it really doesn't look like it to me. So that is why I blocked out vp9 just to be sure. Because I hate that dumb, CPU-inefficient and ugly-looking codec. All the best looking encoders and most efficient software decoders are written for H264.

@mia-0
Copy link
Member

mia-0 commented Dec 5, 2016

I run with software-based CPU decoding on a 6-year old Core i7, where 60 fps @ 1080p leads to dropped frames and stutter.

I really don’t believe this is your CPU’s fault, especially not with YouTube’s streams, unless you’re doing some sort of unreasonable filtering. After all, a Phenom II manages fine, at least for H.264 (never tried VP9 on that particular machine, but I agree that it’s pretty crappy). Also, you can use GPU decoding with filters by using one of the -copy hwdecs. I wonder why you would use “many” filters though.

@MingMingNYC
Copy link

In my case vp9 was picked by default. SteveJobzniak's solution solved the problem.

meribold added a commit to meribold/dotfiles that referenced this issue Nov 19, 2017
Setting `ytdl-format` to `best[height<=768]` (like I did) was a
regression from the default (`bestvideo+bestaudio/best`): it prevents
youtube-dl from using separate sources for video and audio.  (It also
seems 1080p and higher resolutions aren't available on YouTube that way,
though I'm only using 720p on my laptop.)  See [1] and [2].

[1]: mpv-player/mpv#1321
[2]: mpv-player/mpv@78caf6ae8634b9fe9589187d8f
@prog-amateur
Copy link

Hello, thanks to all for sharing the solution. I have a similar issue but the phenomenon is different :
My current config is :
ytdl-format=bestvideo[height<=?1080]+bestaudio/best
When I check the below movie, it works very well :
https://www.youtube.com/watch?v=1Oku4KXWnuI

But with this movie, the video is lagging a lot and the audio is totally not synchronized :
https://www.youtube.com/watch?v=42qZTdwY1eM

So I have changed my config file into :
ytdl-format=bestvideo[height<=?1080][vcodec!=?vp9]+bestaudio/best

After this setting, the second video runs better, but is still lagging a bit with no sync between audio/video.

So I have changed my config file into :
ytdl-format=bestvideo[height<=?1080][fps<=?30][vcodec!=?vp9]+bestaudio/best

Now, both video run perfectly. I guess the solution was to pass the vp9 codec into 30fps.
My question is, I would like to set up 2 parameters :

  1. When the movie is not vp9, I want to keep 60 fps :
    ytdl-format=bestvideo[height<=?1080]+bestaudio/best
  2. And when it is vp9, I want :
    ytdl-format=bestvideo[height<=?1080][fps<=?30][vcodec!=?vp9]+bestaudio/best

How to set up such condition please ? Thank you !

@mrkapqa
Copy link

mrkapqa commented Sep 3, 2019

Hello ,

i would like to prefer vp9 over mp4, how could i achieve that (withouth excluding mp4)?

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