[FFmpeg-devel] [PATCH 1/2] avformat/dashenc: Fix the EXT-X-TARGETDURATION as per the hls specification

Jeyapal, Karthick kjeyapal at akamai.com
Thu Dec 21 19:59:08 EET 2017



>On 12/21/17, 10:15 PM, "Steven Liu" <lingjiujianke at gmail.com> wrote:
>
>2017-12-22 0:37 GMT+08:00 Jeyapal, Karthick <kjeyapal at akamai.com>:
>>
>>
>>>On 12/21/17, 9:47 PM, "Steven Liu" <lingjiujianke at gmail.com> wrote:
>>>
>>>I cannot sure if this patch can fix the problem playlist target
>>>duration not same.
>>>
>>>MacBook:xxx StevenLiu$ ./ffmpeg -hide_banner -i
>>>~/bbb_sunflower_1080p_30fps_normal.mp4 -g 150 -r 100 -x264opts
>>>"scenecut=-1" -f dash -min_seg_duration 1000000 -window_size 99999 -t
>>>5 -hls_playlist 1 output_Steven.mpd
>> That is because the key frames are not getting inserted at the 1 second segment duration.
>Maybe you didn't get the point, i want to say, that is not
>EXT-X-TARGETDURATION and EXTINF's problem, it's just need align in
>multi playlist.
I understand your point. Maybe I am not giving the answer to your point.
But nevertheless, here is my defence :)
In this patch, I am only fixing the issue of target duration not matching with the configured HLS segment duration. That is when configured segment duration is 1 second and the actual segment duration varies from 0.9 sec to 1.1 seconds, then it makes more sense to have target duration as 1 second instead of 2 seconds. And spec allows both 1 seconds and 2 seconds as valid values. But having 1 second as target duration is better as it is the user configured value and is closer to the average duration. That is the reason I submitted http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html in first place.
Now as a side effect this also fixes TARGET-DURATION alignment problem of multiplaylist scenario, when the segment duration is an integral multiple of seconds. Even otherwise it works for most cases except for x.5 second segment durations, and the user doesn’t configure the I frames properly.
1) Theoretically audio duration will not match exactly with the video duration at every segment level, but it will average out in the long run. In your command instead of ‘-t 5’ if you give ‘-t 10’, then target duration is proper as segment durations has got averaged out. 
2) Also, most of the real use-cases is to have segment duration as integer multiple of seconds. Even in hlsenc the segment duration value is configurable only in seconds. So, a segment duration of 1.5 seconds, 2.5 seconds etc., is not yet used by everybody.

So my argument is that this patch fixes target duration issue for audio-only streams and the multiplaylists for majority of the real world use-cases. Some other corner cases for multiplaylist issue is still not handled, which could be handled in a different patch if someone has a real use-case for it. Anyways this patch is required to solve my original issue of “target duration for audio-only streams not matching the configured segment duration”.

>BTW, user not need use  -force_key_frames, just looks like  ffmpeg -i
>input -c copy -f dash xxx.output, then where is the keyframe we don't
>know, the keyframe's interval cannot control by user, just copy from
>source media file.
>
>
>Thanks






More information about the ffmpeg-devel mailing list