Skip to content
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

stream.segmented: add --stream-segmented-duration #5601

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Oct 10, 2023

Closes #5450
Replaces #5493

This PR implements the max stream duration in the SegmentedStreamWorker, as opposed to each worker subclass separately (previously HLSStreamWorker), which is now possible with the switch towards a common Segment base class added in #5594 and the segmented stream changes prior to that (#5498).

--hls-duration has been marked as deprecated, as well as its respective session option.

In the previous attempt (#5493), there were comments about the name of --stream-segmented-duration. This option now affects all segmented stream types, so we need a new name-prefix for that. The other --stream-segment-* CLI args are about individual segments, not about the segmented stream types, so it doesn't make sense using that prefix here. We can't call the new option --stream-duration either, because that would imply that it's possible to limit the duration for all kinds of streams, which is not true.

Also, as mentioned, the related --hls-start-offset option needs to be changed as well in the future. This however requires more code refactoring, because of initialization segments which need to be written to the output first and can't be skipped. There's a fundamentally different implementation in the HLS and DASH streams regarding initialization segments which requires a rewrite of the HLS init segments, so the base SegmentedStreamWorker can work with init segments while skipping the first segments when using the start-offset option. The HLS init segment implementation is rather weird and also incorrect, at least for fragmented MPEG4 segments, as it combines the content of each segment with its init segment, which is unnecessary (still works though). This was done because of MPEG-TS init segments, and nobody could interpret the HLS spec correctly and knew if the "init" segments were a requirement for each segment. (the incorrect behavior was fixed in #5689, but this is all still implemented very badly and requires a full rewrite based on how it's implemented in DASH)

I will keep this PR as a draft until I have the start offset stuff ready because it doesn't make sense having partial/incomplete changes on the master branch.

- Add stream duration logic to `SegmentedStreamWorker`
  and remove it from `HLSStreamWorker`
- Deprecate `--hls-duration` in favor of `--stream-segmented-duration`
  and update the session options respectively
- Update and rename `HLSStreamWorker.duration` attribute
  - Rename from `duration_limit`
  - Don't cast to `int`
- Update log message when ending the stream early
- Add tests
- Add `duration` parameter to `DASHStream`, similar to `HLSStream`
- Update, fix and add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Turn --hls-duration into a generic segmented-stream CLI arg and add support for DASH durations
1 participant