convert video/audio file to audio format with ffmpeg

ffmpeg can convert between different audio formats including MP3, AAC, AIFF, AU-SUN , DTS, WMA, M4A, 

MP2, RA, WAV, AAC, FLAC, OGG, APE.


FFmpeg mp3

This page describes how to use the "lame" encoder within ffmpeg to creates mp3's (ffmpeg apparently has no native mp3 encoder). See also other codecs you could use, and/orAACEncodingGuide for background on FFmpeg audio encoding in general.

VBR Encoding

Example to encode VBR MP3 audio with ffmpeg using the libmp3lame library:

ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3

Control quality with -qscale:a (or the alias -q:a). Values are encoder specific, so for libmp3lame the range is 0-9 where a lower value is a higher quality. 0-3 will normally produce transparent results, 4 (default) should be close to perceptual transparency, and 6 produces an "acceptable" quality. The option -qscale:a is mapped to the -V option in the standalone lame command-line interface tool.

LAME Bitrate Overview
OptionKbit/sBitrate range kbit/sffmpeg equiv.
-b 320320320 CBR (non VBR) example-b:a 320k (NB this is 32KB/s, or its max)
-V 0245220...260-q:a 0 (NB this is VBR from 22 to 26 KB/s...)
-V 1225190...250-q:a 1
-V 2190170...210-q:a 2
-V 3175150...195-q:a 3
-V 4165140...185-q:a 4
-V 5130120...150-q:a 5
-V 6115100...130-q:a 6
-V 710080...120-q:a 7
-V 88570...105-q:a 8
-V 96545...85-q:a 9

In our example above, we selected -qscale:a 2, meaning we used LAME's option -V 2, which gives us a VBR MP3 audio stream with an average stereo bitrate of 170-210 kBit/s.

CBR Encoding

If you need constant bitrate (CBR) MP3 audio, you need to use the -b:a option instead of -qscale:a. Here you can specify the number of bits per second, for example -b:a 256k if you want 256 Kbit/s (25.6 KB/s) audio. Available options are: 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 160, 192, 224, 256, or 320 (add a k after each to get that rate). So to get the highest quality setting, it would be like -b:a 320k.

Troubleshooting

Sometimes it will give you *less* bits per second than you request. If you're doing CBR, it could be because you chose a value "in between" its allowable settings (if defaults down to the next lower). If you're doing VBR, it could be because the input itself is already in a lower bitrate than the requested, in which case, it basically just re-encodes it at the bitrate the input already was. Or possibly that the input was CBR and the VBR aspect is able to reduce bitrate by quite a lot.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值