Remux
Remux the content of file 'in.mkv' to a list of segments 'out-000.nut', 'out-001.nut', etc., and write the list of generated segments to 'out.list':
ffmpeg -i in.mkv -codec hevc -flags +cgop -g 60 -map 0 -f segment -segment_list out.list out%03d.nut
Segment input and set output format options for the output segments:
ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4
Segment the input file according to the split points specified by the segment_times option:
ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 out%03d.nut
Use the ffmpeg
'force_key_frames' option to force key frames in the input at the specified location, together with the segment option 'segment_time_delta' to account for possible roundings operated when setting key frame times.
ffmpeg -i in.mkv -force_key_frames 1,2,3,5,8,13,21 -codec:v mpeg4 -codec:a pcm_s16le -map 0 \ -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 -segment_time_delta 0.05 out%03d.nut
In order to force key frames on the input file, transcoding is required.
Segment the input file by splitting the input file according to the frame numbers sequence specified with the 'segment_frames' option:
ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_frames 100,200,300,500,800 out%03d.nut
Convert the 'in.mkv' to TS segments using the libx264
and aac
encoders:
ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a aac -f ssegment -segment_list out.list out%03d.ts
Segment the input file, and create an M3U8 live playlist (can be used as live HLS source):
ffmpeg -re -i in.mkv -codec copy -map 0 -f segment -segment_list playlist.m3u8 \ -segment_list_flags +live -segment_time 10 out%03d.mkv