-
Notifications
You must be signed in to change notification settings - Fork 64
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
Generate multi-period output #43
Comments
Let me see if I understand correctly. You want Shaka Streamer to stitch together multiple inputs into a continuous output? |
Yes something like that. Just for example:
At the output, we get an hls / dash playlist. |
I think for us, this would be a new type of input in the input.yaml file. But I'm not sure how we would design it offhand. I'll rename the issue and leave this as a feature request in our backlog, but we'd be happy to discuss a design here and review your pull request if you want to tackle it yourself. |
Rough proposal for the input config: inputs:
# The type of input.
- input_type: concat
# The media type is required at this level only.
media_type: video
list:
# These only need to have "name" attributes.
-name: foo1.mp4
-name: foo2.mp4
is_interlaced: True # If you have an interlaced source in the list
# The type of input.
- input_type: concat
# The media type is required at this level only.
media_type: audio
language: "de"
list:
# These only need to have "name" attributes.
-name: foo1.mp4
-name: foo2.mp4
track_num: 2 # If the 0th audio track is not the one you want here... |
There are several ways to concatenate things in ffmpeg, with various limitations.
I haven't tested any of this, but I suspect it's possible to introduce AV desync after the first clip if the audio & video streams of the clips don't match in length. For example:
In this diagram, all audio streams are slightly longer than their video streams. The second clip will be slightly out of sync, and the third even more so. This is my assumption, anyway, based on concatenating the input streams together. If this turns out to be the case, it will be up to the user to make sure their inputs have the same length in audio & video. If Shaka Packager ever introduces multi-period DASH support (for something other than preconditioning for ads), that might be a better option. It would allow boundaries between the different inputs, where the alignment can be reset at each period boundary. But we can go ahead and build this based on concatenating with FFmpeg and switch to Packager-based multi-period at a later date. |
An example of concatenation with ffmpeg: ffmpeg \
-i BigBuckBunny.1080p.webm \
-i Sintel.2010.720p.Small.mkv \
-f mpegts \
-filter_complex "[0:v:0]scale=1920x1080,setsar=1/1[iv0];[1:v:0]scale=1920x1080,setsar=1/1[iv1];[iv0][iv1]concat=n=2:v=1:a=0[outv]" \
-map "[outv]" -y concat-out.ts This is video-only, and the |
@joeyparrish Also we may run the transcoding and the packaging for each input on its own. each input produces a DASH and HLS manifest then in some mechanism, we try to combine the multiple DASH/HLS files from multiple inputs into one DASH/HLS file which includes each individual input as a segment in it. |
That could certainly work, and in fact, combining MPDs by hand is how this clip was produced several years back: But I worry if that is the right approach. It requires an understanding of DASH & HLS structures in Python-land, whereas today that knowledge is entirely delegated to Shaka Packager. On the other hand, editing text files might be relatively painless, and building the ffmpeg commands to concatenate files and adjust their resolutions to match might be awful in practice. Does anyone else have an opinion on this? |
yeah, surely concatenation using ffmpeg is too complicated and restricted compared to concatenation in the .mpd file, also understanding DASH structure is way easier than understanding the ffmpeg's indeed complex |
Ideally the solution would also apply to HLS, perhaps using discontinuities to stitch together content. |
Exactly, I have tried the #EXT-X-DISCONTINUITY and seems to work flawlessly. |
Changes: - Added `multiperiod_inputs_list` to parallel `inputs` for multi-period content - `ConflictingFields` error raised when `inputs` and `multiperiod_inputs_list` fields are present at the same time in the the input config (in `InputConfig.__init__()`) - `MissingRequiredExclusiveFields` error raised when neither `inputs` field nor `multiperiod_inputs_list` field is present (in `InputConfig.__init__()`) - `SinglePeriod` class added to represent each period in the input config - Refactored `controller.start()` to append more Transcoder and Packager nodes - Added `PeriodConcatNode` in `periodconcat_node.py`, a new `ThreadedNode` that is appended after all the Transcoder and Packager nodes. If all of them are finished, it starts the period concatenation. For DASH, the `xml.etree` module is used to parse the `.mpd` files and extract the periods and duration information. For HLS, we might use `m3u8`. - In `ProcessStatus`, `Running` is assigned to a greater value than `Finished` to change the way we wait for all processes to complete, with exceptions made in `CloudNode` and `PeriodConcatNode` Issue #43
It would be very nice to get the playlist function. In order to be able to transfer as an argument xml (or json) a file with a list of media files that will be converted to m3u8 or mpd playlist in turn (non-stop stream).
This is one of the most anticipated features.
The text was updated successfully, but these errors were encountered: