mpv
mpv copied to clipboard
Multiline options in mpv.conf
The formatting for longer option strings can get very unwieldly and barely readable:
I would like to have something like this instead, with newlines and indentation:

Is there a syntax for that?
I used to use something very similar (generated with a little fish script).
I think you can achieve the same with a fairly basic format and format-sort.
ytdl-format=b[ext=mov]/bv+ba/b
ytdl-raw-options=format-sort=[fps,res,vcodec,aext,quality]
I'm not sure about the syntax for the sorting part, because I have mine in my yt-dlp/config, but you get the idea.
Regarding sorting:
vcodec (av01 > vp9.2 > vp9 > h265 > h264 > vp8 > h263 > theora > other)
aext (m4a > aac > mp3 > ogg > opus > webm > other)
Pro Tip: use ytdl-raw-options=yes-playlist= to have YouTube videos in playlists actually open the whole playlist (it will still start with the correct video).
Edit: You could also create a script-opts/osc.config and script-opts/ytdl_hook.config to avoid using script-opts=.
Thanks for all the tips!
I'm using a slightly modified version of https://github.com/TheFrenchGhosty/TheFrenchGhostys-Ultimate-YouTube-DL-Scripts-Collection/blob/master/scripts/Archivist%20Scripts/Archivist%20Scripts/Unique/Unique.sh
Why would they use those long format selection strings if the same result is achievable with format & format-sort?
I'm not sure about the syntax for the sorting part, because I have mine in my yt-dlp/config
Are you saying your mpv sees your yt-dlp config so there's no need to duplicate those options? How does one achieve that?
> h265 > h264
Wouldn't you need to account for "hevc" and "avc" being sometimes used for those codecs respectively? Or is that taken care of now?
I'm using a slightly modified version of https://github.com/TheFrenchGhosty/TheFrenchGhostys-Ultimate-YouTube-DL-Scripts-Collection/blob/master/scripts/Archivist%20Scripts/Archivist%20Scripts/Unique/Unique.sh Why would they use those long format selection strings if the same result is achievable with
format&format-sort?
I don't know why they don't use that. I think that repo has been around for much longer then yt-dlp, and youtube-dl does not support sorting, so maybe they just left things as they were when transitioning to yt-dlp to avoid accidentaly breaking things.
Are you saying your mpv sees your yt-dlp config so there's no need to duplicate those options? How does one achieve that?
mpv calls yt-dlp without the --ignore-config option, so any configuration in .config/yt-dlp/config gets loaded.
Now by default it does pass --format=bestvideo+bestaudio/best, but if you use ytdl-format=ytdl it does not do that, and so the format configuration from your yt-dlp config file will apply.
Wouldn't you need to account for "hevc" and "avc" being sometimes used for those codecs respectively? Or is that taken care of now?
I don't understand what you mean. If you want to avoid them, you could add [vcodec!^=?hevc][vcodec!^=?avc] to your formats.
By default it prefers av01, vp9.2 and vp9 over them.
I don't understand what you mean.
YouTube lists H264 as avc..., and Vimeo lists H265 as hevc..., so wouldn't h265 and h264 end up getting ignored?
Or is there a hard-coded list that accounts for those discrepancies?
I don't know, I've never noticed any unexpected behavior in that regard, but a quick grep over the yt-dlp codebase didn't reveal any definition of aliases. The man page has this though:
E.g. +codec:avc:m4a (equivalent to +vcodec:avc,+acodec:m4a) sets the video codec preference to h264 > h265 > vp9 > vp9.2
> av01 > vp8 > h263 > theora and audio codec preference to mp4a > aac > vorbis > opus > mp3 > ac3 > dts.
Suggesting that it should work. It's probably best if you test it out and if it doesn't work, open an issue over at yt-dlp.
Turns out I was just confused about how the whole format sorting thing works. Only parameter order can be redefined. Sorting within each parameter is predefined, and only a single element within each parameter can be reordered.
There's an issue (https://github.com/yt-dlp/yt-dlp/issues/2260) requesting multiple elements within each parameter to be reorderable.