When the script has been told that an input stream is linear, it supports two options
- Generate full manifest
- Generate manifest with a sliding window
The latter of the two means that older segments will never be requested by the downstream client after a given period (as clients retrieving the manifest for the first time will see a newer segment as the new entry).
Those segments are therefore redundant, so should be removed.
Need to work out the best calculation to use when deciding whether a segment falls into that category though - (manifest length * segment length) * 2 may be slight overkill, but should be sufficient to ensure we don't accidentally remove something that's still live.
As this only applies to live streams, the encoding process(es) should have been forked into the background, the deletion watcher should also be forked so that the script can continue watching for encoding completion (and then kill the deletion watcher).