Creating MPEG-TS (Transport Stream) Segments using FFmpeg

Apple HLS and MPEG-DASH both uses Transport Stream segments.

stream_playlists_2x

Transport Stream can be easily segmented by using ffmpeg.

Here’s the simple way of creating chunks of transport stream for a given segment duration.

$. /ffmpeg -ignore_unknown -i RAImpegCBS.ts -map 0 -codec copy -f segment -segment_time 2 -segment_list out.list segment%3d.ts

ignore_unknown : This is used to ignore any unknown types (SCTE-35, DATA Types). This option may not be available for all the versions of ffmpeg. Check “ffmpeg –help” for list.

i : Input file

map 0 : Maps ALL streams from the first input file to output

codec copy : No conversion/trans-coding of the format. For more codec options check “ffmpeg -codec”

segment_time : Duration of segment

out.list segment%3d.ts : Specifies name of the file listing all the segment and the naming of the segment to be used. In this case segment+3 digit(starting from 0).ts

These segments created by ffmpeg can now be used with either HLS or MPEG-DASH. See Apple’s Documentation on how to create HLS playlist.

Another way to segment is by using ffmpeg hls muxer, for that see hlsbook.net post.