-
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
-AudioBitrateparameters 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
-AudioBitrateparameters 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. 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-5 |
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 |
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 separately; 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. I do not claim to own a copy myself - I've simply added support for those who might have it.
NOTE: DEE wrapper binaries are only included for Windows and Linux systems. I have not heard of a macOS version yet, although the Linux binary should technically work for both.
The DEE Encoder (AKA Dolby Encoding Engine) is an officially sanctioned command-line tool for encoding Dolby audio streams. FFEncoder supports audio encoding with DEE and uses a 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.
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: If you do not choose a supported bitrate, audio encoding will fail without any error message as it's encoded as a separate process.
| 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
|
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 |
Variable |
When a DEE option is selected, the audio is encoded in a separate process 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 DEE audio, you must add it in yourself manually.