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

Specify segment start number #852

Closed
wutchzone opened this issue Oct 9, 2020 · 11 comments
Closed

Specify segment start number #852

wutchzone opened this issue Oct 9, 2020 · 11 comments
Labels
status: archived Archived and locked; will not be updated

Comments

@wutchzone
Copy link

Hello,
When using packager for live video with $Number$ in segment template it would be great to specify from which number to start instead of 0.

Image situation when packager is packing livestream and it crashes (or some maintenance). For failover it would be great if packager would continue with segment number where it ended instead of starting from 0.

Is there a way how to make it possible?

Thanks

@sr1990
Copy link
Contributor

sr1990 commented Oct 9, 2020

Looks like there is a pending PR for initializing start number through packager option: #519. For live streams #818 is in review.

@kqyang
Copy link
Contributor

kqyang commented Oct 10, 2020

@wutchzone As @sr1990 mentioned, the PR (#818) he is working on right now may help. With his change, the segment start number will be generated from the media timestamp.

We will probably still need something like #519 but a variation of it as TS timestamp is only 33 bits.

@jakubvojacek
Copy link

Hello

but starting the segment number from media timestamp will not solve @wutchzone problem right? Because after packager restart, there will be the old segments available but packager's MPD will not point to them. Or do you plan to add some startup check to check for old segments and create the MPD with the old segments as well (and some optional media that will be used to fill the gaps)?

Thank you
Jakub

@wutchzone
Copy link
Author

@sr1990 Yes it looks like that #818 could solve my problem, but it looks like that is only for DASH (as PR name says). I would like to apply this feature to both playlists (DASH && HLS). I imagine something much simpler than detecting the segment number from TS.
For example adding it as argument to the input for packager, example: input=udp://127.0.0.1:10000,stream=0,init_segment=audio0.mp4,segment_template=audio0_$Number$.m4s,start_segment_number=666, then packager would start with audio0_666.m4s and so on.

And as @jakubvojacek mentions it would be cool to detect "old" segments from last run, but I imagine it would be hard to implement.

@sr1990
Copy link
Contributor

sr1990 commented Oct 13, 2020

@jakubvojacek @wutchzone
Because after packager restart, there will be the old segments available but packager's MPD will not point to them. Or do you plan to add some startup check to check for old segments and create the MPD with the old segments as well (and some optional media that will be used to fill the gaps)?
Yes as you mentioned, the PR does not handle this. @kqyang should be able to tell us if this feature can be added.

For example adding it as argument to the input for packager, example: input=udp://127.0.0.1:10000,stream=0,init_segment=audio0.mp4,segment_template=audio0_$Number$.m4s,start_segment_number=666, then packager would start with audio0_666.m4s and so on.
Do you want to create a new mpd or a merged one?
In order to merge, I think you can write a script to merge the mpds into a multi-period one and to address the discontinuity in the merged mpd, can can embed a new period in between pointing to optional media that will be used to fill the gaps as @jakubvojacek has mentioned and also take into consideration time shift buffer depth if required.
@kqyang what do you think?

@Canta
Copy link
Contributor

Canta commented Nov 4, 2020

@wutchzone
In my experience, HLS couldn't care less about the chunk's filename. It checks for the #EXT-X-MEDIA-SEQUENCE tag value: If that's not incremental, players will most likely stall. It means that if you set the proper filename after the restart, but don't change the tag value accordingly to the previous run, it will not work either. That's why last year I've worked in this: #691

I do manage incremental numbers in file names after restarts BTW. I use $Time$ instead of $Number, like this: stuff_$Time%013d$.m4s. That way, the number only goes up. It saves you from the zero, yet not from the gap. Then again, as I use $Time$, I also set the HLS media-sequence tag to a predictable time-based number, and so players are happy.

IDK if this is helpful for your use case, but I did solved my HLS restarts this way.

@wutchzone
Copy link
Author

@sr1990
Sorry for my late response. I have patched the behavior that I have described to my fork of shaka packager. If you are interested I can share it via PR.

@Canta thank you for your hint. But his solves only HLS and I would like to use this behavior in Dash as well as in HLS.

@jakubvojacek
Copy link

@sr1990

In order to merge, I think you can write a script to merge the mpds into a multi-period one and to address the discontinuity in the merged mpd, can can embed a new period in between pointing to optional media that will be used to fill the gaps as @jakubvojacek has mentioned and also take into consideration time shift buffer depth if required.

I was thinking of how to create such a script however I got quite lost. I believe it would be beneficial if there was a sample in the packager docs, would the shaka team be willing to write such an example? :)

Thank you
Jakub

@sr1990
Copy link
Contributor

sr1990 commented Dec 4, 2020

I was thinking of how to create such a script however I got quite lost. I believe it would be beneficial if there was a sample in the packager docs, would the shaka team be willing to write such an example?
@jakubvojacek Sorry for the late reply. The script was just a suggestion. I think @kqyang or someone else from the shaka team can point you in the right direction. Thanks.

@Bec-k
Copy link

Bec-k commented Nov 23, 2021

Any updates on this?

@cosmin
Copy link
Contributor

cosmin commented May 9, 2024

This should be solved after #879 was merged

@cosmin cosmin closed this as completed May 9, 2024
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

No branches or pull requests

9 participants