Log in

View Full Version : Changing the Audio Bitrate of an mp3?


pinkshiro
20th February 2011, 21:16
I'm having some issues with mp3's of variable bitrates in AviSynth and FFMpeg.

My ffmpeg command states -acodec libfaac -ab 192kb -coder 1

The Audio section of my Avi script looks like this:

VideoLength = FrameCount(FinalVideo)
BackgroundMusic=FFAudioSource("pathto\Audio.mp3", cache = false)
tempvid = BlankClip(length=VideoLength)
combinedvid = AudioDub(tempvid, BackgroundMusic)
TrimmedVid = Trim(combinedvid,0,VideoLength)
TrimmedMusic = KillVideo(TrimmedVid)
TrimmedMusic = ConvertToMono(TrimmedMusic)

VideoLength = FrameCount(FinalVideo)
CombinedAudio = Normalize(TrimmedMusic, 0.25)
CombinedAudio = FadeOut0(CombinedAudio, 24)
FinalVideo = AudioDub(FinalVideo, CombinedAudio)

And instead of using FFAudioSource, I have tried using:

BackgroundMusic=MPASource("pathto\Audio.mp3", normalize = false)

But when using MPASource, the last line of my ffmpeg output is:

Error while opening codec for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height

Which leads me to believe that the script is choking on Audio.mp3 whose bitrate is 320kb.

Is there a way to change the audio bitrate of the audio file within Avisynth?

Gavino
20th February 2011, 21:58
Avisynth knows nothing about bitrates - that's a matter for the decoder and encoder, and within Avisynth everything is uncompressed.

I suspect the problem is that MPASource delivers 32-bit audio.
Try using:

BackgroundMusic=MPASource("pathto\Audio.mp3", normalize = false).ConvertAudioTo16Bit()