Radiant Media Player

Working with FFmpeg

Set up

This article describes how to produce MP4 and Apple HLS video files compatible with Radiant Media Player and HTML5 video in general. For this guide with use the latest FFmpeg version available as of August 2015 (N-74546-g5176443) on Ubuntu Desktop LTS 14.04.3 64-bits

Documentation sections:

Installing FFmpeg

General instruction for installing FFmpeg can be found here.

Installing FFmpeg on Linux Ubuntu LTS 14 is quite straight forward. Visit this link taken from FFmpeg official site.

In your terminal enter:

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ffmpeg

And done! No need for advanced compilation command line unless you have a specific need for your FFmpeg build.

On-demand video transcoding to MP4 H.264/AAC (keyframes aligned renditions)

In this section we will review how to produce MP4 files that will work with HTML5 video on devices where H.264 video and AAC audio are supported. Specifically we will produce keyframes aligned video files at different bitrates and resolutions. This is a requirement for adaptive bitrate streaming in MPEG-DASH.

We use a 16:9 1920x1080 24fps (a.k.a. True HD 1080p24) MOV input video file named input.mov. If you need a sample to play around with can get one from blender.org site.

ffmpeg -i input.mov -s 640x360 -c:v libx264 -b:v 600k -r 24 -x264opts keyint=48:min-keyint=48:no-scenecut -profile:v main -preset medium -movflags +faststart -c:a libfdk_aac -b:a 128k -ac 2 out-low.mp4


  • -i input.mov: this is our input video file
  • -s 640x360: we tell FFmpeg to resize our input file to 640x360 while transcoding
  • -c:v libx264: we tell FFmpeg to use x264 as the video encoding library
  • -b:v 600k: the target video bitrate should be 600 kbps
  • -r 24: we want a constant framerate at 24 fps (which is the same as our source video file in this case)
  • -x264opts keyint=48:min-keyint=48:no-scenecut: we should have one keyframe every 48 frames (every 2 seconds). The keyframe injection should be constant
  • -profile:v main: we want H.264 main profile which is supported by most devices on the market while offering good transcoding quality and options
  • -preset medium: we use a medium preset for x264 transcoding
  • -movflags +faststart: the file should be web ready (moov atom before mdat atom)
  • -c:a libfdk_aac: we use libfdk_aac as our audio encoding library
  • -b:a 128k: the target audio bitrate should be 128 kbps
  • -ac 2: we want a stereo (2 audio channels output)
  • out-low.mp4: our output file should be a mp4 file named out-low.mp4

Once we have created our first rendition we can create others at different level of quality. We can then use those renditions directly with Radiant Media Player or through a dedicated streaming solution.

ffmpeg -i input.mov -s 960x540 -c:v libx264 -b:v 1500k -r 24 -x264opts keyint=48:min-keyint=48:no-scenecut -profile:v main -preset medium -movflags +faststart -c:a libfdk_aac -b:a 128k -ac 2 out-med.mp4
ffmpeg -i input.mov -s 1280x720 -c:v libx264 -b:v 2200k -r 24 -x264opts keyint=48:min-keyint=48:no-scenecut -profile:v main -preset medium -movflags +faststart -c:a libfdk_aac -b:a 128k -ac 2 out-high.mp4
ffmpeg -i input.mov -s 1920x1080 -c:v libx264 -b:v 4000k -r 24 -x264opts keyint=48:min-keyint=48:no-scenecut -profile:v main -preset medium -movflags +faststart -c:a libfdk_aac -b:a 128k -ac 2 out-max.mp4

These are examples generic command line. Feel free to play around with the numerous audio and video encoding settings that provide FFmpeg.

H.264 and AAC norms have specific licensing terms which you must met in order to use them. We only provide the above command line as indication on how to achieve proper H.264/AAC transcoding. We do not provide licensing options for H.264/AAC transcoding.

On-demand video packaging to Apple HLS with H.264 video and AAC audio

Apple HLS is popular format for delivering video and audio content to mobile devices and some desktop browsers. Refer to our compatibility table for Radiant Media Player support with Apple HLS.

In this case we use one of our output MP4 files from the first section and we are going to produce a single bitrate Apple HLS stream with FFmpeg:

ffmpeg -i out-med.mp4 -c copy -map 0 -f segment -segment_list playlist.m3u8 -segment_time 10 -bsf:v h264_mp4toannexb -segment_format mpegts stream%05d.ts

Refer to this FFmpeg documentation page for an explanation of the above settings.

An example of output from the above command line can be found here.

Another thing we can do which can come in handy for testing purposes is simulate an Apple HLS live stream from an on-demand MP4 video files:

ffmpeg -re -i out-med.mp4 -c copy -map 0 -f segment -segment_list playlist.m3u8 -segment_time 10 -segment_list_flags +live -bsf:v h264_mp4toannexb -segment_format mpegts stream%05d.ts

Apple HLS EITF specification can be found here.

The examples above are just preliminary works with Apple HLS. Apple HLS offers multiple options like adaptive bitrate streaming, multiple audio or AES-128 encryption/decryption. Generating such sample streams is beyond the scope of this article. Please refer to the above specification for more information on the subject.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License.