4

When extracting Audio streams using ffmpeg from containers such as MP4, how does ffmpeg increase bitrate, if it is higher than the source bitrate?

An example might be ffmpeg -i video.mp4 -f mp3 -ab 256000 -vn music.mp3. What does ffmpeg do if the incoming bitrate is 128k? Does it interpolate or default to 128k on the output music.mp3? I know this seems like not a so-called "programming question" but ffmpeg forum says it is going out of business and no one will reply to posts there.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user3386373
  • 129
  • 1
  • 1
  • 10

1 Answers1

4

During transcoding, ffmpeg (or any transcoder) decodes the input into an uncompressed version; for audio, that's PCM. The encoder compresses this PCM data. It has no idea of, or interaction with, the original source representation.

If no bitrate is specified, ffmpeg will use the default rate control mode and bitrate of the encoder. For MP3 or AAC, that's typically 128 kbps for a stereo output . Although it can be lower, like 96 kbps for Opus. Encoders typically adjust based on no. of output channels. So for a 6-ch output, it may be 320 kbps. If a bitrate is specified, that's used unless the value is invalid (beyond the encoder's range). In which case, the encoder will fallback on its default bitrate selection.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Since MP3 is a 'lossy codec' is it ever possible to get back to the quality of say the original CDA or CD quality level as a PCM? Therefore is there any purpose in Transcoding with a 192K bitrate where the MP3 Compression used 128K bitrate? Hence can one ever get to a high quality WAV from transcoding from a MP3? – user3386373 Nov 09 '17 at 05:07
  • Not possible. Once compressed with a lossy codec, the original data is gone. – Gyan Nov 09 '17 at 05:09
  • Thank you. So in terms of Sound Quality not all PCMs are created equal UNLESS they come from a Losslessly Encoded Format. So using a Lossy encoding means that Transcoding is essentially a waste of time. – user3386373 Nov 09 '17 at 05:49
  • A lossy encoder with a decent bitrate will preserve acceptable quality. And transcoding may be necessary for compatibility. But yes, you can't recover the original. – Gyan Nov 09 '17 at 06:24
  • @Gyan not sure I understand, when android `MediaRecord` records with 128kb/s, and I using ffmpeg to encode to 320kb/s, it is real 320kb/s or just the media information is 320kb/s? – Pavel Poley Jun 10 '22 at 14:24