

Next, we need to specify the input streams that should be included in the output, which we can do with the map command. Lastly, scene change detection is disabled by setting the threshold to zero. We achieve this by setting the GOP size ( -g) to 48, or twice the frame rate of the video input. Apple’s authoring guidelines specify that a key frame should be present every 2 seconds. You may want to play around with the different values to see what works best for you. A slower preset will achieve a better compression ratio but will take longer to run. A preset is a collection of values that determines the “quality” of the encoding. The preset is set to slow the default is medium. This is followed by a number of general encoding options. hls_segment_filename "v%v/fileSequence%d.ts" \ Here’s the ffmpeg command to generate the variants and the master playlist: ffmpeg -y -i sintel_trailer-1080p.mp4 \


(The stream references are highlighted, which we’ll need shortly.) We’ll need to encode the video stream for each variant but we can just copy the audio as is because it’s already encoded as AAC and the bit rate lies within the recommended range (32 to 160 kb/s). We can see there are two available streams: a video and an audio stream. Ignore the warning about the missing output file. Stream #0:1(und): Audio: aac (LC) (mp4a / 0圆134706D), 48000 Hz, stereo, fltp, 126 kb/s (default)Īt least one output file must be specified Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sintel_trailer-1080p.mp4':Ĭopyright : (c) copyright Blender Foundation | ĭescription : Trailer for the Sintel open movie projectĭuration: 00:00:52.21, start: 0.000000, bitrate: 2240 kb/s

The first thing to do is determine what streams are in the video, which we can do with the following command: $ ffmpeg -i sintel_trailer-1080p.mp4 -hide_banner The bit rates will be 2 kB/s and 365 kb/s respectively (as per Apple’s guidelines). We’ll create two variants: a 540p and a 360p version. Apple publishes guidelines for authoring HLS video streams that includes – among other things – recommended video and audio bit rates. The examples below use the 1080p version of the Sintel trailer which you can download here. It allows a client device to choose the most appropriate stream based on factors such as the capabilities of the device, available bandwidth, and so on. In this post you’ll see how to create an HLS master playlist with ffmpeg for video on-demand.Ī master playlist contains references to different variant streams (typically encoded at different bit rates) and can also include links to alternative audio tracks and audio-only renditions.
