yt-dlp reports VP9 in HLS formats with the RFC 6381 codec string, such
as vp09.00.40.08, which matches no codec_map entry. Such tracks get
codec=null in the EDL, and selecting one first initializes an unrelated
decoder. Map vp09.* to vp9.
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
yt-dlp builds the cookies field of each format for the url of that
format and leaves out the Domain attribute when the cookie has an empty
domain in its jar. Cookies imported from a browser can have one, and
the jar then matches them against every url.
Store every cookie the same way and default its domain to the host of
the url the cookies were built for, which makes it a host-only cookie.
The port and userinfo are stripped, since neither libcurl nor lavf
matches a domain that includes them. A cookie that still has no domain
because the url has no http host is dropped.
This includes some cleanup of leftover implementation details of old
lavf cookie option merge, removed in 6017d1fd1c.
Fixes: #18506
This is a revert of a6f3236c3a with bestvideo* added. Dropping the
default format was meant to follow yt-dlp's `bv*+ba/b`, but yt-dlp only
selects that when it finds ffmpeg to merge the tracks. Otherwise it
falls back to `best`, a muxed format, which is most of the time is not
optimal selection.
With use_manifests=yes EDL is not used so metadata never gets set
through the tags mechanism. Thankfully the metadata property was
recently made writable so use that instead.
The existing metadata variable is inlined to fix linting.
Fixes https://github.com/mpv-player/mpv/pull/17761#issuecomment-4306070651
93fe7a5526 fixed the only problem with all_formats=yes, so make it the
default to allow changing tracks of ytdl_hook URLs at runtime without
re-invoking yt-dlp.
Closes#16872.
93fe7a5526 made global_tags work with all_formats=yes, so do like
suggested in 8ea7aa5471 and set the title via tags.
This makes available in ${metadata/title}, even if you set
--force-media-title separately.
--force-media-title is also set when self_redirecting_url is true, but
tags seem not to be set in this case and I don't know where to find such
videos to test. It was originally added to close#5313, but the URL
linked there no longer loads.
The delay_open mechanism used by
--script-opt=ytdl_hook-all_formats=yes breaks setting metadata with
global_tags because tl->track_layout is NULL. See adcf51dccdcbb8f534b08ea7aa5471.
Fix this by applying tags to the EDL timeline in this case.
Tags must still be applied to tl->track_layout when available for them
to work with local EDL files.
Some sites throttle requests, but throttling can be avoided with many
small range requests. yt-dlp implements a "http_chunk_size" key in its
-J output to inform us of the ideal size.
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21703 has just been merged,
which allows use the http_chunk_size to greatly speed up how fast
YouTube videos get loaded into the cache by mpv.
Should the FFmpeg that mpv is built against lack the request_size
AVOption, then this will silently not do anything new, so no version
checks are needed.
Specifying multiple_requests=1 like suggested in
https://github.com/mpv-player/mpv/issues/8655#issuecomment-3872689494
does not seem necessary.
Fixes#8655.
Supersedes #15612.
Co-authored-by: Nicolas F <ovdev@fratti.ch>
This reverts commit e9c43258b8.
yt-dlp implemented its own parsing to extract chapters from the
descriptions of videos without chapter markers in the player over 3
years ago in https://github.com/yt-dlp/yt-dlp/commit/0fe51254 (the PR is
even inspired by mpv). Actually it was present even earlier in
youtube-dl but was removed for unknown reasons in
https://github.com/ytdl-org/youtube-dl/commit/67299f23d8b1894120e875edf97440de87e22308.
So we can remove our parsing code, as it is dead code that never runs if
yt-dlp's JSON already contains chapters.
And it seems that such videos without chapter markers are rare or
non-existing by now anyway - we can't find any.
https://www.youtube.com/watch?v=1v_4dL8l8pQ is linked from the yt-dlp PR
with the above commit, but now yt-dlp returns the Key moments as
chapters, so it can't be used for testing.
Our parsing was actually worse than yt-dlp's, because #16085 added an
option to disable it to fix the misdetection reported in #16081, but
yt-dlp correctly returns no chapter for that video
(https://www.youtube.com/watch?v=1v_4dL8l8pQ). So this code branch was
only running for misdetections, and by removing it that option is not
needed.
yt-dlp changed its default format from `bv+ba/b` to `bv*+ba/b`, which we want to follow
since it fixes the behavior with some streaming sites.
The note that "sometimes youtube-dl returns a format that mpv cannot use" was added in
43c13e5ea2 but it's not clear what it refers to.
fixes#16388
Sometimes when opening a YouTube video with chapters, the chapter-list
ended up having all the chapters twice, despite the json from yt-dlp only
containing them once. That must mean that sometimes add_single_video()
runs twice before the chapter_list table gets cleared in the
on_preloaded hook.
This can be avoided by replacing chapter_list with a new table before
adding entries to it.
Make sure the `early` variable is boolean. The issue was that if url have
`ytdl://`, find() would return position `1`. This makes `early` also `1`.
And now we try to compare `early == load_fail`, which for `1 == true` is
false, while we expect it to be true. Make sure we compare booleans.
Fixes unnecessary hook processing when using ytdl:// protocol.
an empty value to a commandline option usually means that parameter does
not expect anything, but in case of `--proxy`, yt-dlp use an empty value to
disable proxy setting, the empty value need to be passed to `--proxy`
Add support for tracking playlist_title and playlist_id metadata
corresponding to a given playlist url and the entries associated
with it.
This allows the inclusion of ytdl_playlist_title and ytdl_playlist_id
in the metadata property for single videos which have a corresponding
playlist-path property.
This commit also resolvesyt-dlp/yt-dlp#11234
Currently by default mpv sets --all-subs when calling yt-dlp for JSON
info. --all-subs is an option that simply expands to --sub-langs all
--write-subs. --write-subs is special that without it yt-dlp will no
longer extract any subtitle info.
mpv's yt-dlp hook has a logic that if user specify any sub-langs in
--ytdl-raw-options, it no longer uses --all-subs. Unfortunately, this
means unaware users will not get any subtitle any more until they study
the mpv internal code and add their own --write-subs.
This PR always specifies --write-srt, an alias of --write-subs, in the
hook, so users don't have to. The alias is used to maintain
compatibility with youtube-dl.
Fixes issue #14818
By the default mpv tries opening URLs with ffmpeg first, and users who
don't configure try_ytdl_first get a slower startup for youtube URLs, on
top of yt-dlp already being slow.
Fix this by adding a script-opt of URL pattern to try with ytdl first.
Youtube and twitch are included by default.
Compared to the alternative of trying ytdl first by default and
excluding URLs with a media extension, this only works for the sites
explicitly included in the new option's value, but doesn't have false
positives on media URLs without an extension.
It's useful for user scripts to be able to use the same ytdl binary that
ytdl_hook uses without having to replicate ytdl_hook's process of
searching for the ytdl binary.
Some user scripts might also find it useful to be able to access ytdl's
json output that the ytdl_hook already receives, sparing user scripts
from having to make a duplicate ytdl binary invocation to get the json
output.
Providing just the json output is not enough though, as ytdl doesn't communicate
errors though it -- if an error occurs, ytdl provides no json output and instead
prints to stderr. So without stderr, there is no way for user scripts to figure
out why ytdl has failed: no such username / video id, the channel is not live
yet, etc. Because of that, the entire result of the subprocess call is provided
to the user scripts, containing stdout (json), stderr, ytdl's exit code, etc.
For whatever reason, some of the lua code (particularly the osc and
ytdl_hook) is full of a bunch of stuff like if (foo), if not (foo ==
nil), etc. The parenthesis aren't needed in lua and actually just look
weird since nobody actually writes lua like this. You can see most of
the other conditionals are written normally. So cleanup the style to
match when the parenthesis clearly aren't doing anything. Not directly
related, but also add some spaces on a few math operations while we're
at it.
ytdl lists thumbnails in ascending order according to height/preference.
all_formats=yes adds formats from best to worst, so the same should also
be done for thumbnails.
yt-dlp has a preference field for it's thumbnails, and not all of it's
listed thumbnails have fields with their dimensions.
Therefore prefere the preference field when available and fall back to
height if it's not.