How to convert high bitrate mp3 to lower speed using ffmpeg in android

We want to convert a 320kbps mp3 file to 128kbps mp3, so we currently use the ffmpeg command below, but it does not work.

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

Result: - the output bit is the same as the input mp3.

And we follow the FFmpeg Encoding guide, for which there is a link here: - https://trac.ffmpeg.org/wiki/Encode/MP3

please offer any solution.

+5
source share
2 answers

I tried your command shown (tested on Windows / commandline):

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

Result : it works for me. However, -qscale:a 5 allows FFmpeg to decide the average bitrate for you. With one (320k) MP3 file, I got it, giving a close conversion of 134kbps . This is expected because:

 lame option Average kbit/s Bitrate range kbit/s ffmpeg option -V 5 130 120-150 -q:a 5 

Solution :
Instead of internal mp3 frames occupying different bitrates (which vary to fit the "current" perceived sound, for example: think the "silent" parts using a lower bit / byte speed compared to the "occupied" audio parts), so it’s just set a constant bitrate of 128 kbps as needed.

I would just set it to 128 kbps constant manually and explicitly with:

 ffmpeg -i input.mp3 -codec:a libmp3lame -b:a 128k output.mp3 
+2
source

I use this shellscript to not visit this stackoverflow page again and again :)

 #!/bin/bash [[ ! -n $1 ]] && { echo "Usage: mp3convert <input.mp3> <output.mp3> <bitrate:56/96/128/256> <channels> <samplerate>" exit 0 } set -x # print next command ffmpeg -i "$1" -codec:a libmp3lame -b:a "$3"k -ac "$4" -ar $5 "$2" 
0
source

Source: https://habr.com/ru/post/1265776/


All Articles