shaka-project / shaka-packager

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.
https://shaka-project.github.io/shaka-packager/
Other
1.97k stars 507 forks source link

Segment template formatting to create efficient subfolders through time #731

Closed hariszukanovic closed 5 months ago

hariszukanovic commented 4 years ago

Issue and steps to reproduce the problem

When packaging live stream continuously I get a large number of files in the same folder. I would like to avoid this for better file system performance.

What is the expected result?

I would like to create a subfolder structure based on time through "segment template formatting" during the packaging process by using some datetime variable. For example: segment_template=h264_360p/DATE/HOUR_OF_THE_DAY/$Number$.m4s

ffmpeg has a similar feature that I have used successfully in their muxers "ssegment" and "hls" where strftime is applied on the filepath before it is actually used in the packaging process... https://ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment https://ffmpeg.org/ffmpeg-formats.html#Options-6

Would something like that work for shaka packager? For Dash as well?

kqyang commented 4 years ago

@hariszukanovic Do you want to allow the player to seek back, e.g. by more than a day? If not, you can use --time_shift_buffer_depth to limit the buffer depth and Shaka Packager can remove old segments automatically.

As for the feature request itself, it can work for HLS as HLS playlists do not have the concept of segment template and packaging code can replace the time indicator in the template and put it in the playlist.

For Dash as well?

We will need this to be supported by DASH specification which is not right now. We could go with a similar approach as HLS, but that is very inefficient.

If you don't really need these old segments to be seekable by players, and you still want to keep these segments, another option would be to use an external "cron" script to move and rename files.

hariszukanovic commented 4 years ago

Thank you for advice.

For HLS, I suppose this could easily could be supported. I do understand the Dash manifest SegmentTemplate (due to concept) could never support this kind of manipulation with path... SegmentList could support it, but it is not supported/implemented in Shaka packager.

My concrete problem is that I must keep 7 days of chunks, each 1 second long = 604800 files in the same folder. I will seek other solutions for it...

thanx