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
Downloader for slide streams #343
Conversation
For the time-being, please add a |
It can be done with just css animations by setting the animation times using duration. Obviously, I'm not saying you should add it
MHTML is fine imo. The other options would be:
I'm not very familiar with mhtml specs, so expect a full review to take a while |
There is, it’s called MNG. It even has support for JPEG compression too. But it would require re-framing JPEG files into JNG chunks, would be considerably hard to generate and it’s not very widely supported. Before settling on MHTML, I considered putting JPEGs into an MPEG-4 container (complicated to generate), an AVI container (generating RIFF chunks requires knowing the length beforehand, so it would require a second pass over the file), HTML with base64-encoded images might have worked just as well or even better (at least we’d have scripting back), but the ⁴⁄₃ overhead… |
There's also APNG - an extension to the PNG format proposed as an alternative to MNG - which has (after way too many years) managed to achieve widespread support in modern browsers and FFmpeg. It sounds like it might be just what you're looking for. |
APNG would require not only re-framing, but also re-encoding, which I specifically wanted to avoid. |
From pukkandan's earlier comment - "But I dont think there is any motion-png. So we'll need to convert everything to jpeg which is not the greatest idea" - I was under the impression that ideal format would be lossless (in addition to the other requirements). Whether it makes the conversion more challenging to perform on the technical level, I would've expected FFmpeg to be able to handle it. However, I recognise that there likely are intricacies to this which are unfamiliar to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have concerns regarding implementing slides as a "video format" (ie. acodec=none, vcodec=jpeg
)
- This interferes with the format selection. If the user gives
-f wv
(or even worse-f wv+wa
), they are definitely not requesting the slides. Similar issue exists for using-S
- Merger should not try to merge slides with video/audio. Similarly, other postprocessors should also recognize this as not being a standard video/audio format and not try to add metadata, recode, remux etc.
I can think of 2 solutions this to this:
- Add a new key in the infodict for this, similar to thumbnails/subtitles and corresponding cli
--write
option. This is the easiest solution since we don't need to modify any of the existing code - Add a new category
slides
(?) similar to video/audio. This would however require changes to the format selector code, and most (if not all) postprocessors
Whichever solution we decide to implement, it would be helpful if it is easily expandable in the future to allow features like ytdl-org/youtube-dl#14951 without adding yet another type of data
I would also like the user to be able to easily download the images separately without them being embedded into a single mhtml file. This is already somewhat accomplished by using --keep-fragments
, but without the correct file extension. This feature is not necessary to be implemented within this PR though.
Doesn’t a negative preference/quality value mitigate problems with format selection? This is actually part of a more general problem, which Mediasite already hits with some regularity: we don’t handle sites which offer multiple independent, but synchronised streams very well. If I understand correctly, #347 likewise ultimately boils down to this.
I actually thought about doing the opposite and integrating subtitles into the formats list. These are after all synchronised with the other media streams and can be considered a first-class alternative medium of presentation. It’s exactly how FFmpeg treats them, too. (Poster thumbnails, on the other hand, don’t fit into this; they are more akin to metadata tags.) With regard to postprocessor support, this would not have been a problem had I generated an MJPEG stream encapsulated in a Matroska or MP4 container, as I originally planned. Which I think only emphasises that slide sequences should be considered first-class media streams like the others. |
6639111
to
387feda
Compare
This downloader is intended to be used for streams that consist of a timed sequence of stand-alone images, such as slideshows or thumbnail streams.
When using
#347 is a different issue. There, the extractor simply ignores Back to our issue; As I understand,
If we were to consider subtitles/slides as "formats", we are effectively expanding the scope of yt-dlp to allow downloading of subs and slides without any associated video/audio. Not that this is necessarily a bad thing, but is something to think about when deciding on which method to use. Also, if we were to treat slides as normal formats, the mediastream implementation is technically incorrect since the slides and the video are infact totally seperate content (unlike the images from mpd) and should therefore be treated as a seperate video (using I am still leaning towards treating slides seperately than formats if only just for the fact that it is easier to implement and since I don't see any practical benefit to making them first-class citizens. Btw, I've directly pushed some small changes since I thought it would be easier than reviewing. If you dislike any of these changes, let me know |
Also, I already told you this in another PR, but please try to avoid force-pushing once the review process has started. It makes it harder for me to keep track of the changes you are making |
From the documentation:
This implies that |
I agree to this idea. I think there should be a mode for writing out slides/storyboards, since they are absolutely different. Edit: probably not absolutely, but different though |
Another problem with the ‘separate key’ approach is that since storyboards are often embedded in DASH streaming manifests (and I guess they may also appear in other streaming manifests), supporting them uniformly everywhere might require the same kind of API churn that #247 had to involve, with all the |
This is a good point. But I am not sure how to improve this situation (without massive changes ofc). If you have any suggestions, we can discuss it (in a new issue preferably)
This can be worked around by letting the extractor add the storyboards as just another format and then plucking it out into a new key. I had the same idea for subtitles, but I never mentioned it since you had already replaced the functions But in that case, it may be cleaner to just directly treat it as a format in that case, although it is a lot more work. Assuming we are going by that approach, how would we handle an option to download the images seperately? With the other approach, I was thinking something like With the "formats method", we would need 2 separate formats and separate selectors (eg: |
Necessary for #343. * They are identified by `vcodec=acodec='none'` * These formats show as the worst in `-F` * Any postprocessor that expects audio/video will be skipped * `b*` and all related selectors will skip such formats * This commit also does not add any selector for downloading such formats. They have to be explicitly requested by the `format_id`. Implementation of a selector is left for when #389 is resolved
I have added minimum support for images format in 8326b00. With this, formats with With that, this should be now ready for merge. I'll wait for your reply however in case you want to make any other changes |
A priori, |
How so?
How is it a barebones video stream? It is not a video format and no video player / video processing tool will recognize it as such |
MHTML is not a video format. But the image stream itself is not too hard to squeeze into one, as mentioned before. The DASH storyboards should be easy to mux into an MJPEG stream in an MP4 container using FFmpeg’s Subtitles were mentioned before as another timed media stream that is neither audio or video. FFmpeg also supports abstract timed data streams (TTML subtitles are currently only parsed as those). Though subtitles are already special-cased and I doubt we might ever deal with more abstract data, the inference ‘if it’s neither audio nor video, then it’s an image sequence’ does not seem particularly, ahem, sound. |
fair enough, but a more generalized implementation will need to be rewritten again when implementing #389. Hence why I don't want to put any more effort into it |
Okay then. Like I said, it’s not that bad, especially for a stop-gap measure. |
This downloader is intended to be used for streams that consist of a timed sequence of stand-alone images, such as slideshows or thumbnail streams This can be used for implementing: ytdl-org/youtube-dl#4974 (comment) ytdl-org/youtube-dl#4540 (comment) ytdl-org/youtube-dl#11185 (comment) ytdl-org/youtube-dl#9868 ytdl-org/youtube-dl#14951 Authored by: fstirlitz
I have merged this as 2 commits - one for the downloader, and another for mediasite |
Postponing DASH then? |
No, it is in cdb19aa I only split out mediasite coz it is extractor specific and not really part of the core feature |
I should have mentioned the DASH storyboards in the commit message... I tried adding a |
Necessary for yt-dlp#343. * They are identified by `vcodec=acodec='none'` * These formats show as the worst in `-F` * Any postprocessor that expects audio/video will be skipped * `b*` and all related selectors will skip such formats * This commit also does not add any selector for downloading such formats. They have to be explicitly requested by the `format_id`. Implementation of a selector is left for when yt-dlp#389 is resolved
This downloader is intended to be used for streams that consist of a timed sequence of stand-alone images, such as slideshows or thumbnail streams This can be used for implementing: ytdl-org/youtube-dl#4974 (comment) ytdl-org/youtube-dl#4540 (comment) ytdl-org/youtube-dl#11185 (comment) ytdl-org/youtube-dl#9868 ytdl-org/youtube-dl#14951 Authored by: fstirlitz
Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
This implements a downloader for slideshow-like streams and uses it to download slides from Mediasite presentations and also thumbnail streams found in DASH manifests.
The hardest part was probably picking the format for the downloaded slides. I needed a format that is:
Given these constraints, my only option was… MHTML. This is admittedly an unorthodox choice for a media format, and it should be noted that basically the only major software that supports it now are Blink-based browsers. Nevertheless, thanks to the HTML stub included in the file, the slideshow in the file can be readily viewed in those. I would have even included an interactive player, if it weren’t for the fact that Chromium doesn’t run scripts in MHTML files, so it would have been a considerable effort to implement something that wouldn’t even be usable; thus, I limited myself to including some basic CSS to make the slideshow passively viewable in a browser. Should the user want to extract the images, they will have no problem finding software libraries to process MIME multipart messages.
This addresses: