[FFmpeg-devel] [PATCH v1] avformat/hlsenc: fix hls_time not respected

Ingo Oppermann ingo at datarhei.com
Mon Jan 27 22:18:35 EET 2025


> On 27 Jan 2025, at 11:41, Gyan Doshi <ffmpeg at gyani.pro> wrote:
> 
> 
> 
> On 2025-01-27 01:56 pm, Ingo Oppermann wrote:
>>> On 24 Jan 2025, at 16:30, Gyan Doshi <ffmpeg at gyani.pro> wrote:
>>> 
>>> 
>>> 
>>> On 2025-01-24 05:29 pm, Ingo Oppermann wrote:
>>>> This fixes the criterion when to split the segments based on the elapsed time
>>>> for the current segment instead of using the theoretical elapsed time since
>>>> start based on hls_time and the number of written segments.
>>>> 
>>>> hls_time is used to define the minimum length of a segment, however this is
>>>> not respected in all cases when a stream has variable GOP sizes.
>>>> 
>>>> Imagine a stream starts with a key frame every 10 seconds for e.g. 40 seconds.
>>>> After that, key frames will come every second. This will result in segments
>>>> that are first 10 seconds, then 1 second for some time and later 2 seconds as
>>>> expected.
>>> Better to make it flexible like how the segment muxer does it, by having an optional minimum segment duration parameter. Then it's upto the user.
>>> See d39b34123d.
>> According to the documentation "hls_time" is already supposed to be the minimum duration of a segment: "Segment will be cut on the next key frame after this time has passed." (https://ffmpeg.org/ffmpeg-formats.html#Options-26).
> 
> In practice, the logic used is that segment X,  counting from 0, should start at X*hls_time. It's not best practice to change long-standing behaviour without a fallback or workaround. Your patch doesn't offer that.
> HLS is usually a multiple representation format, so this may adversely affect rendition switchability. Adding an option like segment muxer won't change the outcome of existing command lines but will still allow you the behaviour you're looking for.

That's true. Changing the current behaviour might break existing processes that are based on this specific behaviour. I'll add a new option then.

> 
> Regards,
> Gyan
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".




More information about the ffmpeg-devel mailing list