-
Notifications
You must be signed in to change notification settings - Fork 1
Audio Options
FFEncoder supports the mapping/transcoding of 2 distinct audio streams to the output file. For audio that is transcoded, the primary audio stream is used as it's generally lossless (TrueHD, DTS-HD MA, LPCM, etc.). It is never recommended to transcode from one lossy codec to another; if the primary audio stream is lossy compressed, it is best to stream copy it instead of forcing a transcode.
FFEncoder currently supports the following audio options wih the -Audio
/-Audio2
parameters. When selecting a named codec (like EAC3, AC3, etc.) the script will go through the following checks:
- If either of the
-AudioBitrate
parameters are selected, the corresponding stream will be transcoded to the selected codec, regardless if an existing stream is present in the input file - If the
-AudioBitrate
parameters are not present, the script will search the input file for a matching stream and stream copy it to the output file if found - If no bitrate is specified and no existing stream is found, then the script will transcode to the selected codec at the default bitrates listed below:
Type | Values | Default | Description |
---|---|---|---|
Copy |
copy , c
|
N/A | Passes through the primary audio stream without re-encoding |
Copy All |
copyall , ca
|
N/A | Passes through all audio streams from the input to the output without re-encoding |
AAC | aac |
512 kb/s | Converts the primary audio stream to AAC using ffmpeg's native CBR encoder. Compatible with the -AudioBitrate parameters |
FDK AAC |
fdkaac , faac
|
Variable (VBR) | Converts the primary audio stream to AAC using libfdk_aac. Compatible with the -AudioBitrate parameters. See note below for more info |
AAC_AT | aac_at |
Variable (VBR) | Converts the primary audio stream to AAC using Apple Core Audio Toolbox (MacOS only). Compatible with the -AudioBitrate parameters |
AC3 |
ac3 , dd
|
640 kb/s | Dolby Digital. Compatible with the -AudioBitrate parameters |
E-AC3 | eac3 |
448 kb/s | Dolby Digital Plus. Compatible with the -AudioBitrate parameters |
DTS | dts |
Variable (VBR) | DTS Core audio. If the source audio is DTS-HD MA, the core is extracted without re-encoding. Warning: ffmpeg's DTS encoder is "experimental". Compatible with the -AudioBitrate parameters |
FLAC |
flac , f
|
Variable (VBR) | Converts the primary audio stream to FLAC lossless audio using ffmpeg's native FLAC encoder |
Stream # | 0-12 |
N/A | Select an audio stream using its stream identifier in ffmpeg/ffprobe. Not compatible with the -Stereo parameters |
None |
none , n
|
N/A | No audio streams will be added to the output file |
Additional encoding options exist if you have the Dolby Encoding Engine. See below for more info.
FFEncoder includes support for Fraunhofer's libfdk_aac, even though it is not included in a standard ffmpeg executable. Due to a conflict with ffmpeg's GPL, libfdk_aac cannot be distributed with any official ffmpeg binaries, but it can be included when compiling ffmpeg manually from source. For more info, see Dependencies.
One of the benefits of the FDK encoder is that it supports variable bitrate (VBR). When using the -AudioBitrate
/-AudioBitrate2
parameters with fdkaac
, values 1-5 are used to signal VBR. 1 = lowest quality and 5 = highest quality.
When running FFEncoder on a Mac computer, you gain access to the AudioToolbox AAC encoder (open source port of Apple's high quality encoder) via the aac_at
argument. AudioToolbox is, by default, a variable Bitrate (VBR) encoder, but can accept the following values using -AudioBitrate
/-AudioBitrate2
:
-
-1
- Auto (VBR) -
0
- Constant bitrate (CBR) -
1
- Long-term Average bitrate (ABR) -
2
- Constrained variable bitrate (VBR) -
3
- Variable bitrate (VBR)
With FFEncoder, you can downmix either of the two output streams to stereo using the -Stereo
/-Stereo2
parameters. The process uses an audio filter that retains the LFE (bass) track in the final mix, which is discarded when using -ac 2
in ffmpeg directly.
When using any combination of copy
/c
/copyall
/ca
and -Stereo
/-Stereo2
, the script will multiplex the primary audio stream out of the container and encode it in a separate thread; this is because ffmpeg cannot stream copy and filter at the same time. See here for a nice explanation. Once the primary encode finishes, the external audio file (now converted to stereo) is multiplexed back into the primary container with the other streams selected.
DISCLAIMER: The script does not provide a copy of the DEE encoder, only the compiled wrapper program.
The DEE Encoder (AKA Dolby Encoding Engine) is an proprietary command-line tool for encoding Dolby audio streams. FFEncoder supports audio encoding with DEE which uses a platform-specific, custom-compiled version of deew to parse the parameters passed to the script; while the script is written in Python, you do not need Python installed to use the compiled wrapper.
Before the deew
wrapper will work properly, you first need to set the configuration file path as it is no longer included as a sidecar file by default. Open a PowerShell (or bash) window, navigate to the /bin/<os>
directory within FFEncoder, and run the following command:
# Force regenerate the configuration file
# Windows
.\deew.exe -gc
# Linux
./deew -gc
This should prompt you for a save path with 2 options:
- The default location (OS specific)
- The directory where the executable is saved
Choose option 2, as this is where FFEncoder will look for the config file. The config file will be generated afterward in the location you chose. The file settings should look like the following:
# These are required.
# If only name is specified, it will look in your system PATH variable, which includes the current directory on Windows.
# Setup instructions: https://github.com/pcroland/deew#setup-system-path-variable
# If full path is specified, that will be used.
ffmpeg_path = 'ffmpeg'
ffprobe_path = 'ffprobe'
dee_path = 'dee'
# FFEncoder will set this for you - leave it empty
temp_path = ''
# THIS MUST BE DISABLED
logo = 0
# Change this if you want but 50% is a reasonable default
max_instances = '50%'
# Set these to whatever you want
[default_bitrates]
dd_1_0 = 128
dd_2_0 = 256
dd_5_1 = 640
ddp_1_0 = 128
ddp_2_0 = 256
ddp_5_1 = 1024
ddp_7_1 = 1536
# THESE MUST ALL BE DISABLED
[summary_sections]
deew_info = false
binaries = false
input_info = false
output_info = false
other = false
If you don't disable the options marked above, the script will fail as it cannot decode the unicode characters that the rich
library prints when embedded in a different script.
To use deew
, the following 3 things must be available via PATH (the first two are already required by FFEncoder):
- ffmpeg
- ffprobe
- dee
I made a few changes to the XML templates used in deew
based on recommendations from audio engineers. Otherwise, all credit goes to pcroland for writing the code (although I've contributed a bit to the repo).
To encode audio with DEE, use the following arguments for either the Audio
or Audio2
parameters:
NOTE: The parameters options
dee_ddp_51
/dee_eac3_51
are used to force a downmix from 7.1 to 5.1 for an 8-channel audio source. To force a stereo downmix (LtRt), use theStereo
/Stereo2
parameters.
Codec | Argument | Supported Bitrates |
---|---|---|
Dolby Digital Plus (E-AC3) 7.1 |
dee_ddp , dee_eac3
|
384, 448, 576, 640, 704, 768, 832, 896, 960, 1008, 1024, 1280, 1536, 1664 |
Dolby Digital Plus (E-AC3) 5.1 |
dee_ddp , dee_eac3 , dee_ddp_51 , dee_eac3_51
|
192, 200, 208, 216, 224, 232, 240, 248, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1008, 1024 |
Dolby Digital Plus (E-AC3) 2.0 LtRt / 1.0 Mono |
dee_ddp , dee_eac3
|
96, 104, 112, 120, 128, 144, 160, 176, 192, 200, 208, 216, 224, 232, 240, 248, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1008, 1024 |
Dolby Digital (AC3) 5.1 |
dee_ac3 , dee_dd
|
224, 256, 320, 384, 448, 512, 576, 640 |
Dolby Digital (AC3) 2.0 LtRt / 1.0 Mono |
dee_ac3 , dee_dd
|
96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640 |
TrueHD | dee_thd |
N/A (Variable Bitrate) |
When a DEE option is selected, the audio is encoded in a separate thread to improve speed - when both encodes are completed, the script multiplexes the audio back into the primary container for you. If the video encode finishes before the audio, the script will wait for both to complete before progressing.
Note that if you do not choose a supported bitrate, audio encoding will fail - adding verification logic is time consuming, so just reference the table above and all will be well.
If the script is throwing an error when using one of the DEE compatible options, it is most likely due to a rogue configuration file in the default deew
file path. To verify this, navigate to the /bin/<os>
directory once more and run the following command:
# Print config location and settings
.\deew.exe -c
If the output prints 2 locations (and the printed settings are not correct), delete the file that is not saved in the FFEncoder project directory. This should resolve the problem.