![]() |
MainConcept xHE-AAC Encoder Plug-in for FFmpeg 3.1.0
|
The following briefly describes how to use the MainConcept xHE-AAC Encoder plug-in for FFmpeg.
The command line format should follow the structure below, depending on which operating system you are using.
The following is a sample command line for encoding xHE-AAC at 128 kbps for On-Demand use-cases (further explanations and examples are covered below):
ffmpeg -i ffsource_f32_2ch.wav -c:a omx_enc_xheaac -omx_core omxil_core.dll -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass1ExpLoud=loudness.bin" -f null - -y
ffmpeg -i ffsource_f32_2ch.wav -b:a 128000 -c:a omx_enc_xheaac -omx_core omxil_core.dll -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass2ImpLoud=loudness.bin:streamID=1" output_omx.mp4 -y
/opt/mainconcept/ffmpeg-omx/bin/
. Ensure this folder is in your search path for the following examples.The following is a sample command line for encoding xHE-AAC at 128 kbps for On-Demand use-cases (further explanations and examples are covered below):
ffmpeg -i ffsource_f32_2ch.wav -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass1ExpLoud=loudness.bin" -f null /dev/null - -y
ffmpeg -i ffsource_f32_2ch.wav -b:a 128000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass2ImpLoud=loudness.bin:streamID=1" output_omx.mp4 -y
All settings below are optional parameters for omx_param parameters (mc-general-params/mc-codec-params).
Function | Description |
---|---|
b:a | Specifies whether to use CBR (Constant) or VBR (Variable) modes with corresponding bitrate. If you want to use CBR, set a bitrate in bps, e.g. -b:a 128000 . This is basically an FFmpeg parameter for specifying bitrates for CBR. It allows you to set up all bitrates supported by xHE-AAC and legacy AAC specifications. If you want to configure the encoder for VBR mode, the parameter must not be set. For available bitrates, see the Appendix. |
profile: a | Specifies the built-in encoder profile. It can be set as: -profile: a [profile number] . Available profiles are: - 1: AAC LC (AOT 2) - 4: HE-AAC (AOT 5) - 28: HE-AACv2 (AOT 29) - 41: xHE-AAC (AOT 42) |
omx_param | Specifies parameters from the xHE-AAC Encoder to use on the command line. Use : as a separator and = as a value set for the key. -omx_param "pass1ExpLoud=loudness.bin:vbrMode=4:streamID=1: ..." These arguments match the xHE-AAC Encoder settings. See Parameters for more details. |
The MainConcept xHE-AAC Encoder plug-in can be used for both on-demand (file-based) and live encoding workflows based on FFmpeg. These two use-cases require specific modes to be set on the FFmpeg command-line. A more detailed explanation of these settings can be found under Parameters.
For file-based xHE-AAC workflows, it is required to carry out two-pass encoding by applying the following parameters:
In the first pass, the input waveform is analyzed and the loudness data as well as other stream characteristics are measured. It is not necessary to specify any bitrates or other settings to carry out xHE-AAC encoding and or where drcMode should be applied. Other parameters are ignored in this pass.
The second pass will apply the data obtained from the first pass and perform the actual encoding. Provided the input file, codec and drcMode stays the same, it is possible to call the second pass multiple times to generate different bitrates, file formats or other stream variants.
For xHE-AAC live encoding workflows only, it is possible to run the FFmpeg plug-in in single pass encoding mode. The following parameter must be set for this scenario:
Enabling this option applies dynamic signal-adaptive gains to the input signal prior to the actual encoding process, ensuring a consistent playout loudness level.
The MainConcept xHE-AAC Encoder plug-in for FFmpeg comes with the following encoder settings and parameters that can be specified on the command-line using -omx_param.
pass1ExpLoud
pass2ImpLoud
liveLoudnessLevel
liveLoudnessRelMaxGain
liveLoudnessMode
drcMode
targetLRA
streamID
rapInterval
vbrMode
The command-line examples below are Linux specific. To run examples on Windows, you must slightly modify them. Instead of -omx_core libomxil_core.so
you need to specify -omx_core omxil_core.dll
on Windows.
The FFmpeg plug-in supports encoding of On-Demand content (typically file-to-file) where the input is a non-live signal source. Depending if xHE-AAC or legacy AAC encoding is being used, there are some differences on how the plug-in operates.
For xHE-AAC, the plug-in requires a two-pass encoding procedure.
The first pass analyzes the input waveform and measures loudness data and other characteristics. The user does not need to enter any encoding bitrates or other specifics besides the fact that he wants to encode with xHE-AAC and which drcMode he wants to use. Other parameters are ignored in this pass. For a given input file, codec and drcMode, the first pass needs to be carried out once only.
The second pass will use that data and perform the actual encoding. As long the input file, codec and drcMode, stays the same, the user can call the second pass multiple times to generate different bitrates, file formats or other stream variants.
When encoding for adaptive streaming use-cases, ensure a unique streamID is chosen in pass 2 for every bitstream that will end up in one adaptation set.
The following example generates a simple MP4 file with xHE-AAC as a codec and a cbr bitrate of 128 kbps. The resulting MP4 file has the first sample marked as SyncSample and additionally Independent Frames (IF) are marked in a SampleGroup of type 'prol'. The encoding is carried out in two passes. The first pass will measure the loudness and some other key characteristics and write that to an intermediate file. The second pass will carry out the actual encoding.
ffmpeg -i <file_src.wav> -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass1ExpLoud=loudness.bin" -f null - -y
ffmpeg -i ffsource_f32_2ch.wav -b:a 128000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass2ImpLoud=loudness.bin:streamID=1" output_omx.mp4 -y
The default FFmpeg to write an MP4 file is to write "mdat" first and "moov" last. This method of writing is acceptable for storage but cannot be used when the file should be decodable while being downloaded. This is usually called "progressive download" and requires the "moov" header before the "mdat".
This can be configured by telling FFmpeg to write "moov" first with the flag: "+faststart".
ffmpeg -i <file_src.wav> -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass1ExpLoud=loudness.bin" -f null - -y
ffmpeg -i ffsource_f32_2ch.wav -b:a 128000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass2ImpLoud=loudness.bin:streamID=1" -movflags +faststart output_omx.mp4 -y
This example generates a fragmented MP4 file with xHE-AAC as a codec and a cbr bitrate of 128 kbps. The fragment duration is set to ~4 seconds. This sample command-line is helpful when the manifest generation is to be carried out in a later step without FFmpeg or if the mp4-based streaming format required is not supported by FFmpeg.
ffmpeg -i <file_src.wav> -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass1ExpLoud=loudness.bin" -f null - -y
ffmpeg -i <file_src.wav> -b:a 128000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass2ImpLoud=loudness.bin:streamID=1:rapInterval=4000" -movflags frag_keyframe+empty_moov output_omx.mp4 -y
The frag_keyframe
command controls when FFmpeg should close/start a fragment. For a streaming environment, it is highly recommended to place a RAP/SAP at the beginning of a fragment. This is achieved by making use of frag_keyframe
. The fragments will be aligned to the RAP/SAP signaling set by the encoder via rapInterval
.
To tell FFmpeg not to write sample related data into the moov header and only into the fragments (which is required/used for most of the streaming formats), the empty_moov
flag must be specified.
This example demonstrates how to create an xHE-AAC MP4-based DASH set with a single audio representation, otherwise using the same parameters regarding codec configuration as in previous examples. In this specific case an OnDemand DASH stream with file segments and a manifest with template-based segment access is being created.
rapInterval
encoder parameter. There is no need to make use of additional dash muxer segment length configuration.ffmpeg -i <file_src.wav> -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass1ExpLoud=loudness.bin" -f null - -y
ffmpeg -i <file_src.wav> -b:a 128000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass2ImpLoud=loudness.bin:streamID=1:rapInterval=4000" -f dash -use_timeline 0 -mpd_profile 4 output_omx.mp4 -y
The following example demonstrates how to create an xHE-AAC MP4-based HLS set with a single audio representation, otherwise using the same parameters for codec configuration as in previous examples. In this specific case, an OnDemand (VOD) HLS stream with file segments, media manifest and master manifest is created.
rapInterval
encoder parameter. It is not necessary to use additional HLS multiplexer segment length configuration.ffmpeg -i <file_src.wav> -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass1ExpLoud=loudness.bin" -f null - -y
ffmpeg -i <file_src.wav> -b:a 128000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass2ImpLoud=loudness.bin:streamID=1:rapInterval=4000" -f hls -hls_playlist_type vod -hls_flags independent_segments -master_pl_name output_master.m3u8 -hls_segment_type fmp4 output_media.m3u8 -y
The encoder can be used with Constant Bitrate (CBR) and Variable Bitrate (VBR) encoding modes. To enable VBR, remove the b:a
option for CBR and add a suitable vbrMode
.
The following example encodes xHE-AAC and vbrMode 4:
ffmpeg -i <file_src.wav> -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass1ExpLoud=loudness.bin" -f null - -y
ffmpeg -i <file_src.wav> -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "pass2ImpLoud=loudness.bin:streamID=1:vbrMode=4" output_omx.mp4 -y
The following examples demonstrate how to generate simple MP4 files with xHE-AAC as a codec and live mode activated. The parameter liveLoudnessLevel
is provided to enable live processing.
liveLoudnessRelMaxGain
and liveLoudnessMode
parameters. If not provided externally, the relative maximum gain will be internally set to the default value of 33 dB.ffmpeg -i <live_src> -b:a 32000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "streamID=1:rapInterval=4000:liveLoudnessLevel=-24.0" output.mp4 -y
ffmpeg -i <live_src> -b:a 32000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "streamID=1:rapInterval=4000:liveLoudnessLevel=-24.0:liveLoudnessRelMaxGain=33.0" output.mp4 -y
ffmpeg -i <live_src> -b:a 32000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "streamID=1:rapInterval=4000:liveLoudnessLevel=-24.0:liveLoudnessMode=1" output.mp4 -y
The following example demonstrates how to generate an xHE-AAC MP4 based MPEG-DASH set with a single audio representation. In this case, a live DASH stream with segments and a manifest file with template-based segment access is created.
rapInterval
encoder parameter. It is not necessary to perform any additional MPEG-DASH multiplexer segment length configuration.ffmpeg -i <live_src> -b:a 32000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 41 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "streamID=1:rapInterval=4000:liveLoudnessLevel=-24.0" -f dash -use_timeline 0 live1 output.mpd -y
For legacy AAC aots (2, 5, 29) the encoder always runs in single-pass encoding mode. The only required parameter (besides the aot value) is either the cbr bitrate or the vbr mode. Loudness, drc and streamID features are not supported.
Adaptive Streaming use cases are supported, but only where bitstreams are encoded with the same aot.
The following example generates a simple MP4 file with AAC-LC as a codec and a cbr bitrate of 128 kbps. The encoding is carried out in one pass.
ffmpeg -i ffsource_f32_2ch.wav -b:a 128000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 1 -omx_name OMX.MainConcept.enc_xheaac.audio output_omx.mp4 -y
The next example generates a fragmented MP4 file with AAC-LC as a codec and a cbr bitrate of 128 kbps. The fragment duration is set to ~4 seconds. This example command line is helpful for when the manifest generation is carried out at a later step without FFmpeg or if the MP4-based streaming format required is not supported by FFmpeg.
ffmpeg -i ffsource_f32_2ch.wav -b:a 128000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 1 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "rapInterval=4000" -movflags frag_keyframe+empty_moov output_omx.mp4 -y
The frag_keyframe
command controls when FFmpeg should close/start a fragment. For a streaming environment, it is highly recommended to place a RAP/SAP at the beginning of a fragment. This is achieved by making use of frag_keyframe
. The fragments will be aligned to the RAP/SAP signaling set by the encoder via rapInterval
.
To instruct FFmpeg not to write sample-related data into the moov header and only into the fragments (which is required/used for most of the streaming formats), the empty_moov
flag must be specified.
This example demonstrates how to create an AAC-LC MP4-based DASH set with a single audio representation, using the same parameters for codec configuration as in previous examples. In this specific case, an on-demand DASH stream with file segments and a manifest with template-based segment access is created.
rapInterval
encoder parameter. It is not necessary to use additional DASH multiplexer segment-length configuration.ffmpeg -i ffsource_f32_2ch.wav -b:a 128000 -c:a omx_enc_xheaac -omx_core libomxil_core.so -profile:a 1 -omx_name OMX.MainConcept.enc_xheaac.audio -omx_param "rapInterval=4000" -movflags frag_keyframe+empty_moov -f dash -use_timeline 0 -mpd_profile 4 output_omx.mp4 -y
This appendix contains information on the following:
Depending on the AAC family codec, only certain bitrates are allowed. Refer to the tables below for information on the allowed and recommended bitrate ranges.
Sampling frequency (hz) | Channel config | Minimum bitrate (kbit/s) | Minimum recommended bitrate (kbit/s) | Maximum recommended bitrate (kbit/s) | Maximum bitrate (kbit/s) |
---|---|---|---|---|---|
44100 / 48000 | Mono | 6 | 12 | 96 | 128 |
44100 / 48000 | Stereo | 12 | 16 | 256 | 320 |
Sampling frequency (hz) | Channel config | Minimum bitrate (kbit/s) | Minimum recommended bitrate (kbit/s) | Maximum recommended bitrate (kbit/s) | Maximum bitrate (kbit/s) |
---|---|---|---|---|---|
44100 / 48000 | Mono | 16 | 24 | 48 | 64 |
44100 / 48000 | Stereo | 24 | 32 | 96 | 128 |
44100 / 48000 | 5.1 | 64 | 128 | 256 | 320 |
44100 / 48000 | 7.1 | 96 | 192 | 320 | 448 |
Sampling frequency (hz) | Channel config | Minimum bitrate (kbit/s) | Minimum recommended bitrate (kbit/s) | Maximum recommended bitrate (kbit/s) | Maximum bitrate (kbit/s) |
---|---|---|---|---|---|
44100 / 48000 | Stereo | 18 | 24 | 32 | 48 |
Sampling frequency (hz) | Channel config | Minimum bitrate (kbit/s) | Minimum recommended bitrate (kbit/s) | Maximum recommended bitrate (kbit/s) | Maximum bitrate (kbit/s) |
---|---|---|---|---|---|
44100 / 48000 | Mono | 40 | 56 | 96 | 128 |
44100 / 48000 | Stereo | 64 | 96 | 256 | 320 |
44100 / 48000 | 5.1 | 160 | 256 | 384 | 448 |
44100 / 48000 | 7.1 | 224 | 320 | 512 | 640 |