0

I am trying to convert a .flac audio file into an .mp3 at different bitrates. The simple code is the following:

import ffmpy
ff = ffmpy.FFmpeg(inputs={'in.flac': None},outputs={'out.mp3': None})
ff.run()

Now, since I want my out.mp3, let's say, at 320k, I modify the second line of the code as follows:

ff = ffmpy.FFmpeg(inputs={'in.flac': None},outputs={'out.mp3': '-ab 320k'})

The problem is that I am not sure I am using the right command in the right position, by inserting

'-ab 320k' 

or

'-ab 320000'

The script seems to run correctly and Python does the conversion into mp3 but the bitrate is always 128 (I am checking it by using eyed3). How can I modify my code to get 320kbps?

  • Confirm that it's not a bug of eyed3 by dividing the size of the generated MP3 by its duration. – Gyan Nov 04 '16 at 15:58
  • I don't think it's a bug. I've tried to encode various .flac into .mp3 with audacity and the eyed3 command gives me the correct bitrates. – shoegazerstella Nov 04 '16 at 16:21
  • Maybe, but eyed3 may not be parsing the ffmpeg MP3 correctly. Just eliminate that possibility first. – Gyan Nov 04 '16 at 16:22
  • I am using this specific function `f = mp3.Mp3AudioFile('path/filename.mp3') bitrate = f.info.bit_rate print(bitrate)` how can I be sure if it's working or not? – shoegazerstella Nov 04 '16 at 16:26
  • Download one of the MP3s locally and divide its filesize by the duration. – Gyan Nov 04 '16 at 18:42

1 Answers1

0

try this:

ff = ffmpy.FFmpeg(
 inputs={'16 Bit Lolitas - Beat Organ (Original Mix).mp4': None},
 outputs={'16 Bit Lolitas - Beat Organ (Original Mix).mp3': ['-ab', '320k']}
)