ffmpeg处理hls

ffmpeg处理m3u8格式

一、处理m3u8的常用命令
1、保存m3u8为flv
ffmpeg -re -i http://192.168.14.102:8080/live/2012.m3u8 -vcodec copy -acodec copy -bsf:a aac_adtstoasc -f flv d:\2012.flv

2、使用segment切片ts文件为m3u8
ffmpeg -i D:\media\2012.ts -vcodec copy -acodec copy -scodec copy -f segment -segment_list D:\media\hls\out.m3u8 -segment_list_flags +live -segment_list_entry_prefix ./ -segment_time 5 D:\media\hls\out%03d.ts

如果含多节目,指定第一个:
ffmpeg -i D:\media\2012.ts -vcodec copy -acodec copy -scodec copy -map 0 -f segment -segment_list D:\media\hls\out.m3u8 -segment_list_flags +live -segment_list_entry_prefix ./ -segment_time 5 D:\media\hls\out%03d.ts

flv转码兼切片为m3u8:
ffmpeg -i E:\video\mystream.flv -acodec copy -bsf:a h264_mp4toannexb -g 105 -vcodec libx264 -vprofile baseline -bf 0 -bufsize 850k -bsf:v dump_extra -map 0 -f segment -segment_format mpegts -segment_list "E:\video\hls\mystream.m3u8" -segment_time 10 E:\video\hls\mystream\rec-%d.ts

3、使用hls切片ts文件为m3u8
ffmpeg -i D:\media\2012.ts -vcodec copy -acodec copy -scodec copy -f hls -hls_time 5 -hls_base_url ./ -hls_segment_filename D:\media\hls\in_%03d.ts D:\media\hls\in.m3u8

这个需要服务器先开启才行,只是作为例子,没有实际价值:
ffmpeg -i D:\media\2012.ts -vcodec copy -acodec copy -scodec copy -f hls -hls_time 5 -hls_list_size 10 -hls_base_url ./ http://192.168.14.100:1234/1.m3u8

4、摄像头采集后的数据直接编码切片m3u8
ffmpeg -f dshow -i video="Integrated Camera":audio="麦克风 (Realtek High Definition Au" -s 640*480 -vcodec libx264 -acodec libmp3lame -flags -global_header -map 0 -f segment -segment_time 10 -segment_list live.m3u8 -segment_list_entry_prefix ./ -segment_list_flags +live -segment_format mpegts live%05d.ts


二、处理m3u8的muxer设置
1、segment
segment muxer AVOptions:
-reference_stream <string> E....... set reference stream (default "auto")
-segment_format <string> E....... set container format used for the segments
-segment_format_options <string> E....... set list of options for the container format used for the segments
-segment_list <string> E....... set the segment list filename
-segment_header_filename <string> E....... write a single file containing the header
-segment_list_flags <flags> E....... set flags affecting segment list generation (default 1)
cache E....... allow list caching
live E....... enable live-friendly list generation (useful for HLS)
-segment_list_size <int> E....... set the maximum number of playlist entries (from 0 to INT_MAX) (default 0)
-segment_list_type <int> E....... set the segment list type (from -1 to 4) (default -1)
flat E....... flat format
csv E....... csv format
ext E....... extended format
ffconcat E....... ffconcat format
m3u8 E....... M3U8 format
hls E....... Apple HTTP Live Streaming compatible
-segment_atclocktime <int> E....... set segment to be cut at clocktime (from 0 to 1) (default 0)
-segment_time <string> E....... set segment duration
-segment_time_delta <duration> E....... set approximation value used for the segment times (default 0)
-segment_times <string> E....... set segment split time points
-segment_frames <string> E....... set segment split frame numbers
-segment_wrap <int> E....... set number after which the index wraps (from 0 to INT_MAX) (default 0)
-segment_list_entry_prefix <string> E....... set base url prefix for segments
-segment_start_number <int> E....... set the sequence number of the first segment (from 0 to INT_MAX) (default 0)
-segment_wrap_number <int> E....... set the number of wrap before the first segment (from 0 to INT_MAX) (default 0)
-strftime <int> E....... set filename expansion with strftime at segment creation (from 0 to 1) (default 0)
-individual_header_trailer <int> E....... write header/trailer to each segment (from 0 to 1) (default 1)
-write_header_trailer <int> E....... write a header to the first segment and a trailer to the last one (from 0 to 1) (default 1)
-reset_timestamps <int> E....... reset timestamps at the begin of each segment (from 0 to 1) (default 0)
-initial_offset <duration> E....... set initial timestamp offset (default 0)

2、hls
hls muxer AVOptions:
-start_number <int64> E....... set first number in the sequence (from 0 to I64_MAX) (default 0)
-hls_time <float> E....... set segment length in seconds (from 0 to FLT_MAX) (default 2)
-hls_list_size <int> E....... set maximum number of playlist entries (from 0 to INT_MAX) (default 5)
-hls_ts_options <string> E....... set hls mpegts list of options for the container format used for hls
-hls_wrap <int> E....... set number after which the index wraps (from 0 to INT_MAX) (default 0)
-hls_allow_cache <int> E....... explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments (from INT_MIN to INT_MAX) (default -1)
-hls_base_url <string> E....... url to prepend to each playlist entry
-hls_segment_filename <string> E....... filename template for segment files
-hls_flags <flags> E....... set flags affecting HLS playlist and media file generation (default 0)
single_file E....... generate a single media file indexed with byte ranges
delete_segments E....... delete segment files that are no longer part of the playlist
round_durations E....... round durations in m3u8 to whole numbers
discont_start E....... start the playlist with a discontinuity tag
omit_endlist E....... Do not append an endlist when ending stream
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值