[Feature Request] Sites offering alternative simultaneous media streams
See original GitHub issue- I’m reporting a feature request
- I’ve verified that I’m running yt-dlp version 2021.06.08
- I’ve searched the bugtracker for similar feature requests including closed ones
Description
(Spun off from #343)
A handful of sites sometimes offer multiple media streams of a given type that are meant to be played simultaneously or as alternatives to each other. The biggest one is probably Mediasite, which often offers a screencast stream (and presentation slides) in addition to the video stream showing the speaker. Other such cases are possible: in the past, GDCVault offered an alternative audio track containing the translation of the speaker’s talk, and a video stream containing the slides; #347 is an issue with a site offering both subtitled and dubbed versions of the same video.
This is not very common, but when it happens, it’s something of a pain to support. Currently, alternative Mediasite streams are offered as separate formats with a negative preference value, which means they are not downloaded by default, even though we can do it just fine. Because it is nowhere even mentioned that they are available for download, they can be hard to discover (see ytdl-org/youtube-dl#20611, ytdl-org/youtube-dl#23003). Some kind of general framework for handling such cases would be useful.
Here’s my design sketch: each format can declare a set of streams it contains by including a 'streams'
key in its dict containing a non-empty list of stream identifiers (strings). If two formats declare the same stream identifier, they shall be considered as containing two different quality versions of the same content. If a format doesn’t have a 'streams'
key, it will be synthesised based on the 'acodec'
and 'vcodec'
keys: the list will contain 'audio'
unless 'acodec'
is 'none'
and it will contain 'video'
unless 'vcodec'
is 'none'
.
The meaning of best
would then be modified, and a couple of other selectors added:
best
: Picks the single best pre-multiplexed format that contains all streams;allbest
: For each stream offered by the download, picks the best format containing it, and downloads them separately;mergeallbest
: For each stream offered by the download, picks the best format containing it, and merges them all afterwards. If merging is not possible, nothing is selected.
The default value of the -f
option would then become mergeallbest/allbest
. Analogous selectors for the worst formats could be provided as well.
List of extractors that could potentially benefit (with example URLs if possible):
- Animelab offers both Japanese-dubbed and English-dubbed audio streams, and both hard-subbed and non-subbed video (#347)
- Mediasite offers slide and screencast video streams
- http://mediasite.uib.no/Mediasite/Play/90bb363295d945d6b548c867d01181361d?catalog=a452b7df-9ae1-46b7-a3ba-aceeb285f3eb (requires
--no-check-certificates
for the moment)
- http://mediasite.uib.no/Mediasite/Play/90bb363295d945d6b548c867d01181361d?catalog=a452b7df-9ae1-46b7-a3ba-aceeb285f3eb (requires
- FranceTV offers audio description tracks
- https://www.france.tv/france-2/les-invisibles/les-invisibles-saison-1/2764261-garenne.html (not downloadable by myself; may be geoblocked or no longer available)
- SVTPlay offers something they call ‘Clear Speech’
- YouTube serves alternative audio for some videos and some multifeed videos, currently handled as playlists (note the alternative stream has its own ID):
- https://youtu.be/rs1WF2SkjuY: normal and audio description audio streams
- https://www.youtube.com/watch?v=LnlKwzc_TNA: audio streams in seven different languages
- https://www.youtube.com/watch?v=mp0TW8vkCLg, https://www.youtube.com/watch?v=7jQ5wLZ6Pj4: multifeed videos (currently each feed is handled as a separate video, as each has separate ID; this one may be left as-is)
- ArteTV is known to serve the same media dubbed into different languages (mostly French and German). V1 API returns versions with burned-in subtitles in different language versions (#3086) and audio description streams.
- https://www.arte.tv/fr/videos/104351-002-A/serviteur-du-peuple-1-23/ (v1 API offers burned-in subtitle variants)
- https://www.arte.tv/de/videos/102958-001-A/in-therapie-staffel-2-1-35/ offers French and German language audio, with AD (Hörfilm) and hard-of-hearing (Hörgeschädigte) variants for both languages
- https://github.com/yt-dlp/yt-dlp/pull/3302#issuecomment-1112897663 also mentions each stream comes with a different type of subtitle (forced/visual-only, HOH, translation), which also need to be distinguished
- TF1 serves audio in multiple language versions (#982)
- Zoom offers screen recording stream to download, in parallel with camera stream (#2523): no links available, though
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:14 (11 by maintainers)
Related to this issue, YouTube now allows some videos to have 2 audio tracks such as a descriptive audio track for the blind. So yt-dlp defaults to picking
251-1
only.Both
251-0
and251-1
should get muxed with251-1
selected as the default audio track when the muxed output video file gets played.This is a great idea and shouldn’t be too difficult to implement.
There are however a few things that need addressing:
bestvideo
should always select the one best video stream irrespective of it’s stream typebestvideo.presentation
)bestvideo.all
orallbestvideo
)best
to mean the multiplexed format with ALL streams could cause compat issues. Say there is a website that providesaudio+video
merged and we add story boards for it. Now if someone was using-f best
, it will throw error since now there is no single format with all stream types. So we should keepbest
to refer to any format with 1 video + 1 audioallbest
/mergeallbest
creates an ambiguity. Sincebest
refers to the best multiplexed format,allbest
intuitively refers to the best of each stream-type that has multiplexed formatsDue to these, I propose that we keep the video|audio(|image?) selector as-is, and add the stream selector on top of this. So the format selector will look like:
Here’s how it would address the above points
bestvideo
-> best video of any stream typebest*.presentation
-> best format (audio/video/per-merged) of type presentationbestvideo.screencast
-> best video-only format of type screencastbestvideo.all
-> Best of each type of video-only streams, downloaded seperatelymergebest*.all
-> Best of each type of stream merged into 1 fileWe haven’t changed the meaning of
best
, but we also now don’t have any selector to select “pre-merged format with all stream types”. I will need to think about how this can be added, or if it is even neededbest.all
-> best pre-merged format of each stream typebest*.all
-> Best of each type of stream, whether audio, video or pre-mergedall.screencast
-> All formats of type screencast Note thatall
before and after the.
has different meanings