音频 编码

来自艺搜天下
跳到导航 跳到搜索

基础

尽量避免音频转码

ffmpeg -i someFile.webm -c:a copy -c:v libx264 outFile.mkv

use 64 kBit/s for each channel(so 128 kBit/s for stereo, 384 kBit/s for 5.1 surround sound). CBR

ffmpeg -y -i input.mp4 -c:v libx264 -b:v 933k -preset:v veryfast -pass 1 -an /dev/null
ffmpeg -i input.mp4 -c:v libx264 -b:v 933k -preset:v veryfast -pass 2 -ac 2 -c:a libfdk_aac -b:a 128k output.mp4

VBR

追求质量, Set the VBR level with the -vbr #5 is highest quality

ffmpeg -i input.wav -c:a libfdk_aac -vbr 3 output.m4a

High-Efficiency AAC

HE-AAC version 1:

ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he -b:a 64k output.m4a

HE-AAC version 2:适于低于32kb/s的

ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he_v2 -b:a 32k output.m4a

常用的格式

Dolby Digital: ac3
Dolby Digital Plus: eac3
MP2: libtwolame, mp2
Windows Media Audio 1: wmav1(不建议用)
Windows Media Audio 2: wmav2(不建议用)
AAC LC: libfdk_aac, aac
HE-AAC: libfdk_aac
Vorbis: libvorbis, vorbis(不建议用)
MP3: libmp3lame, libshine
Opus: libopus

质量排序:

libopus> libvorbis> = libfdk_aac> aac> libmp3lame> = eac3 / ac3> libtwolame> vorbis> mp2> wmav2 / wmav1

容器支持的音频格式

MKV/MKA	:Opus, Vorbis, MP2, MP3, LC-AAC, HE-AAC, WMAv1, WMAv2, AC3, eAC3, 
MP4/M4A	:MP2, MP3, LC-AAC, HE-AAC, AC3
FLV/F4V	:MP3, LC-AAC, HE-AAC
3GP/3G2	:LC-AAC, HE-AAC
MPG	:MP2, MP3
PS/TS Stream	:MP2, MP3, LC-AAC, HE-AAC, AC3
M2TS	:AC3, eAC3
VOB	:MP2, AC3
RMVB	:Vorbis, HE-AAC
WebM	:Vorbis, Opus
OGG	:Vorbis, Opus

建议使用的码率

假设采样率为44.1kHz或48kHz,双声道:

libopus   ≥ 64Kbps
libfdk_aac default AAC LC profile   ≥ 128Kbps
libfdk_aac -profile:a aac_he_v2  可用范围 ≤ 48Kbps CBR. 
libfdk_aac -profile:a aac_he 可用范围 ≥ 48Kbps and ≤ 80Kbps CBR.
libvorbis   :-aq 4 (≥ 128Kbps)
libmp3lame : -aq 2 (≥ 192Kbps)
ac3 or eac3 : ≥ 160Kbps   # ffmpeg -i input.wav -c:a libfaac -q:a 330 -cutoff 15000 output.m4a
aac ≥ 128Kbps
libtwolame:≥ 256Kbps
mp2 :≥ 320Kbps
码率计算:(bitrate for stereo) x (channels / 2).  #6 channels Vorbis audio: 128Kbps x (6 / 2) = 384Kbps 

参考

https://trac.ffmpeg.org/wiki/Encode/AAC

http://trac.ffmpeg.org/wiki/Encode/HighQualityAudio