[FFmpeg-devel] [PATCH] hlsenc: intialize only on ref_pkt (v2)

Miroslav Slugeň thunder.m at email.cz
Tue Feb 14 11:45:09 EET 2017


Dne 14.2.2017 v 09:33 Steven Liu napsal(a):
> 2017-02-14 16:30 GMT+08:00 Miroslav Slugeň <thunder.m at email.cz>:
>
>> Dne 14.2.2017 v 04:59 Steven Liu napsal(a):
>>
>> 2017-02-13 21:15 GMT+08:00 Miroslav Slugeň <thunder.m at email.cz>:
>>> This patch will fix cutting hls segments into exactly same length. Because
>>>> it will intialize only on first ref_packet, which is video frame, not
>>>> audio
>>>> frame (old behavior)
>>>>
>>>> Now it should be possible to create segments at exactly same length if we
>>>> use new -force_key_frames hls:time_in_seconds parameter.
>>>>
>>>> This is required to support adaptive HLS.
>>>>
>>>> This patch was splitted to two parts, this is first independent part
>>>>
>>>> --
>>>> Miroslav Slugeň
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> ffmpeg-devel mailing list
>>>> ffmpeg-devel at ffmpeg.org
>>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>>
>>>>
>>>> Patch can compile passed, but i cannot reproduce the problem before your
>>> patch, can you send a reproduce step and test file?
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel at ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>> I can provide you with sample. But this explanation should be enough:
>>
>> When you use -copyts for long time audio/video sync when transcoding from
>> MPEGTS stream, audio comes always sooner than video (it is around 1-2 s),
>> so hlsenc is initialized with audio packet PTS instead of video packet PTS.
>> That is not correct if you wan't to have all segments with same length
>> -forced_keyframes to force keyframe at video position. Every other
>> calculations of hls_time is done only on ref_packets which is video. This
>> scenario is problematic when encoder is also inserting keyframes by its own
>> decision (libx264 default behavior).
> command line please!
>
>>
>> M.
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
ffmpeg -i dvb_record.ts \
-map 0:v:0 -filter:v yadif -force_key_frames 'expr:gte(t,n_forced*10)' 
-c:v libx264 -g 250 -b:v 500k \
-map 0:a:0 -ac 2 -ar 48000 -c:a libfdk_aac -b:a  128k \
-sn \
-copyts \
-r 25 \
-hls_time 10 -hls_list_size 10 -hls_allow_cache 1 -use_localtime 1 
-hls_flags omit_endlist+discont_start \
-hls_segment_filename "segment-%Y%m%d-%s.ts" -f hls -y "playlist.m3u8"

But this will not work correctly until -force_key_frames is fixed for 
copyts, or until you use -force_key_frames hls:10 from my patch "[PATCH] 
ffmpeg: add new forced_keyframes option hls:time"

M.


More information about the ffmpeg-devel mailing list