convert audio to mp3, recode mp3 file
You could use this command:
ffmpeg -i input.wav -vn -ar 44100 -ac 2 -b:a 192k output.mp3
Explanation of the used arguments in this example:
-
-i
- input file -
-vn
- Disable video, to make sure no video (including album cover image) is included if the source would be a video file -
-ar
- Set the audio sampling frequency. For output streams it is set by default to the frequency of the corresponding input stream. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options. -
-ac
- Set the number of audio channels. For output streams it is set by default to the number of input audio channels. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options. So used here to make sure it is stereo (2 channels) -
-b:a 192k
- Converts the audio bit-rate to be exact 192 KB/s (192 kibibit per second).But maybe use
-q:a 2
instead, which allows the encoder to pick from 170 to 210 KB/s quality-range (average 192 KB/s). But-q
format may not be compatible with some old player-hardware.
Note to see docs about bit-rate argument's differences. Because maybe that option is the most important one, as it decides the "quality" versus "output size" versus "old mp3-player compatibility".
Where:
-b:a
is for CBR (constant-bit-rate), which should be compatible with most old players, but may take more file-size.-q:a
or-qscale:a
alias, is for VBR (variable-bit-rate).--abr
is for ABR (adaptive-bit-rate), which is a combo of CBR and VBR modes, but--abr
argument needs-b
to be passed as well (becauseffmpeg
does not take any parameters after--abr
, unlikelame --abr
executable).
来源:https://stackoverflow.com/questions/3255674/convert-audio-files-to-mp3-using-ffmpeg