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

ytdl_hook should respect youtube-dl's config file #7422

Closed
rndusr opened this issue Feb 1, 2020 · 7 comments
Closed

ytdl_hook should respect youtube-dl's config file #7422

rndusr opened this issue Feb 1, 2020 · 7 comments

Comments

@rndusr
Copy link

rndusr commented Feb 1, 2020

I have this line in my ~/.config/youtube-dl/config:

--format bestvideo[height<=720][vcodec!*=av01]+bestaudio/bestvideo[height<=1080][vcodec!*=av01]+bestaudio/best[height<=720][vcodec!*=av01]/best[height<=1080][vcodec!*=av01]/best

It should pick a non-av01 video if possible. If I run youtube-dl <YouTube URL>, this works as expected. But if I run mpv <YouTube URL> --msg-level ytdl_hook=trace, I can see that youtube-dl is called with --format bestvideo+bestaudio/best.

  1. According to the man page, bestvideo+bestaudio/best is already the default: "Since the end of April 2015 and version 2015.04.26, youtube-dl uses -f bestvideo+bestaudio/best as the default format selection (see vo_gpu: Segfault when switching scaler and pausing simultaneously (hwdec=vdpau) #5447 (Document and make default --format='bestvideo+bestaudio/best' ytdl-org/youtube-dl#5447), Protocol whitelist in ytdl_hook #5456 ([YoutubeDL] Make bestvideo+bestaudio/best default format when merger is available ytdl-org/youtube-dl#5456))."

  2. ytdl_hook should respect my preferences.

It also enforces --sub-format ass/srt/best and --all-subs, which I would leave to the user to configure.

I could fix this by adding ytdl-raw-options ... to my ~/.config/mpv/mpv.conf, but then I'd have to maintain the same settings in two different files.

@wiiaboo
Copy link
Member

wiiaboo commented Feb 3, 2020

It could be argued that you might not want the same settings to download videos as well as streaming them.

We would need to stop setting a default format, since we're for sure not going to check if youtube-dl.conf exists and has a format line, as the path for it changes for all platforms, or even doing youtube-dl and parsing the debug output.

Other than format ytdl_hook respects your youtube-dl.conf as it's directly calling youtube-dl without --ignore-config. We just need to set format to set some sane defaults.

At most I'd agree with a way to prevent ytdl_hook from setting those defaults if --ytdl-format is also unset.

@rndusr
Copy link
Author

rndusr commented Feb 3, 2020 via email

@wiiaboo
Copy link
Member

wiiaboo commented Feb 3, 2020

Yes, it's copied from youtube-dl's default, not actually using youtube-dl's default.

@wiiaboo
Copy link
Member

wiiaboo commented Feb 3, 2020

mpv should fail like youtube-dl does: $ youtube-dl --format 'video[height<=360]' 'https://www.youtube.com/watch?v=y-fLkdVRMwE' [...] requested format not available

If you use a bad format value, ytdl's -J still returns all the formats and defaults to bestvideo+bestaudio/best for the requested_url or requested_formats key. That's youtube-dl's intended behavior of -J, not an issue in ytdl_hook or youtube-dl.

@ghost
Copy link

ghost commented Feb 3, 2020

There were also some cases mpv couldn't handle, while youtube-dl could (since youtube-dl has its own code for dash etc.).

@rndusr
Copy link
Author

rndusr commented Feb 3, 2020 via email

@rndusr rndusr closed this as completed Feb 3, 2020
@sergeykish
Copy link

Release 0.33.0 adds

--ytdl-format=ytdl

The ytdl value does not pass a --format option to youtube-dl at all, and thus does not override its default. Note that sometimes youtube-dl returns a format that mpv cannot use, and in these cases the mpv default may work better.

43c13e5

This includes default format too, no --format bestvideo+bestaudio/best:

$ cat .config/mpv/mpv.conf 
ytdl-format=ytdl
$ mpv  --msg-level=ytdl_hook=trace ...
...
[ytdl_hook] Running: youtube-dl --no-warnings -J --flat-playlist --sub-format ass/srt/best --all-subs --no-playlist -- ...

Thank you!

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