Make HLS Playlist
Use following command to record webcam and encode to MPEG-TS then make playlist:
ffmpeg -f avfoundation -i "0" -hls_list_size 5 -hls_flags append_list -hls_flags omit_endlist -start_number 0 -hls_allow_cache 0 -hls_segment_filename ./segments/live%03d.ts -hls_base_url segments/ live.m3u8
The segments will save tosegments
folder.
live.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:9
#EXT-X-MEDIA-SEQUENCE:4
#EXTINF:8.333333,
segments/live004.ts
#EXTINF:8.333333,
segments/live005.ts
#EXTINF:8.333333,
segments/live006.ts
#EXTINF:8.333333,
segments/live007.ts
#EXTINF:2.433333,
segments/live008.ts
Use ffplay to test.
ffplay -v debug live.m3u8
[file @ 0x7fee21e8cd60] Setting default whitelist 'file,crypto'
[hls,applehttp @ 0x7fee2302b400] Format hls,applehttp probed with size=2048 and score=100
[hls,applehttp @ 0x7fee2302b400] HLS request for url 'segments/live006.ts', offset 0, playlist 0
Format mpegts probed with size=2048 and score=50
[mpegts @ 0x7fee2301da00] stream=0 stream_type=1b pid=100 prog_reg_desc=
[hls,applehttp @ 0x7fee2302b400] Before avformat_find_stream_info() pos: 285 bytes read:285 seeks:0 nb_streams:1
[h264 @ 0x7fee2302e800] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x7fee2302e800] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x7fee2302e800] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x7fee2302e800] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 0x7fee2302e800] Reinit context to 1280x720, pix_fmt: yuv422p
[h264 @ 0x7fee2302e800] no picture
[hls,applehttp @ 0x7fee2302b400] max_analyze_duration 5000000 reached at 5000000 microseconds st:0
[hls,applehttp @ 0x7fee2302b400] Setting avg frame rate based on r frame rate
[hls,applehttp @ 0x7fee2302b400] After avformat_find_stream_info() pos: 285 bytes read:285 seeks:0 frames:152
Input #0, hls,applehttp, from 'live.m3u8':
Duration: N/A, start: 51.466667, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0, 152, 1/90000: Video: h264 (High 4:2:2), 1 reference frame ([27][0][0][0] / 0x001B), yuv422p(left), 1280x720, 0/1, 30 fps, 30 tbr, 90k tbn, 60 tbc
Metadata:
variant_bitrate : 0
[FFmpeg HLS document](https://www.ffmpeg.org/ffmpeg-formats.html\#hls-1\)