support split hls segment at duration set by hls_time after the patch , the ffmpeg can split the mpegts for hls by hls_time parameter
[root@localhost ffmpeg]# ./ffmpeg -i /root/facebook.mp4 -v quiet -c copy -f hls -hls_time 3 -hls_flags split_by_time -bsf:v h264_mp4toannexb -hls_list_size 20 -t 30 output_afterpatch.m3u8 [root@localhost ffmpeg]# [root@localhost ffmpeg]# [root@localhost ffmpeg]# cat output_afterpatch.m3u8 #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:4 #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:3.040000, output_afterpatch0.ts #EXTINF:3.160000, output_afterpatch1.ts #EXTINF:2.840000, output_afterpatch2.ts #EXTINF:3.160000, output_afterpatch3.ts #EXTINF:2.880000, output_afterpatch4.ts #EXTINF:3.080000, output_afterpatch5.ts #EXTINF:2.920000, output_afterpatch6.ts #EXTINF:3.120000, output_afterpatch7.ts #EXTINF:2.880000, output_afterpatch8.ts #EXTINF:2.960000, output_afterpatch9.ts #EXTINF:-0.040000, output_afterpatch10.ts #EXT-X-ENDLIST support split hls segment at duration set by hls_time Signed-off-by: LiuQi <li...@gosun.com> --- libavformat/hlsenc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index a9fa5d8..5dc518d 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -62,6 +62,7 @@ typedef enum HLSFlags { HLS_ROUND_DURATIONS = (1 << 2), HLS_DISCONT_START = (1 << 3), HLS_OMIT_ENDLIST = (1 << 4), + HLS_SPLIT_BY_TIME = (1 << 5), } HLSFlags; typedef enum { @@ -813,7 +814,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) if (hls->has_video) { can_split = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && - pkt->flags & AV_PKT_FLAG_KEY; + ((pkt->flags & AV_PKT_FLAG_KEY) || (hls->flags & HLS_SPLIT_BY_TIME)); is_ref_pkt = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO; } if (pkt->pts == AV_NOPTS_VALUE) @@ -923,6 +924,7 @@ static const AVOption options[] = { {"round_durations", "round durations in m3u8 to whole numbers", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_ROUND_DURATIONS }, 0, UINT_MAX, E, "flags"}, {"discont_start", "start the playlist with a discontinuity tag", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DISCONT_START }, 0, UINT_MAX, E, "flags"}, {"omit_endlist", "Do not append an endlist when ending stream", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_OMIT_ENDLIST }, 0, UINT_MAX, E, "flags"}, + {"split_by_time", "split the hls segment by time which user set by hls_time", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SPLIT_BY_TIME }, 0, UINT_MAX, E, "flags"}, {"use_localtime", "set filename expansion with strftime at segment creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, {"use_localtime_mkdir", "create last directory component in strftime-generated filename", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, {"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type), AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E, "pl_type" }, -- 1.7.1
0001-add-split_by_time-flag-for-support-splite-mpegts-seg.patch
Description: Binary data
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel