12

I want to first decode a MP3 audio file, and then increase the volume of the audio, and then encode it again into a new MP3 file. I want to use libavformat or libavcodec for this. Can you help me how I can do this? Any example?

Blue Sky
  • 293
  • 1
  • 5
  • 14

1 Answers1

16

You can use the "-filter" parameter with the "volume" option to set a multiplier for the audio. More info: http://ffmpeg.org/ffmpeg-filters.html#volume

Since you are dealing only with MP3 files (that have only one audio track), you can use the "-af" parameter, which is an alias for "-filter:a".

For instance,

ffmpeg -i input.mp3 -af 'volume=1.5' output.mp3

would increase the volume in 50% and create the output file with the same codec as input (MP3).

moropus
  • 3,672
  • 1
  • 22
  • 30
Gabriel Magno
  • 375
  • 2
  • 11
  • a warning about above command: I tested with an ogg file, and while it works, and the volume got increased, it also changed the internal encoding of the audio stream from vorbis to flac, making the file unusable in android. so you may want to add some parameters to keep the original encoding. – cesarpachon Feb 14 '16 at 02:21