Radiant Media Player

Working with FFmpeg



Set up

This article describes how to produce MP4 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 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

Explanation:

  • -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.

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