How to change the bit rate of audio while converting from midi file to mp3 using ffmpeg/fluidsynth

893 Views Asked by At

I am trying to convert midi file to mp3 using fluidsynth and ffmpeg on Windows 10 OS.

fluidsynth -a alsa -T raw -F - "FluidR3Mono_GM.sf3" simple.mid |  ffmpeg -ab 192k -f s32le -i  simple.mp3

The audio bit rate specification : -ab 192k or -b:a 192k are creating an error:

You are applying an input option to an output file or viceversa.

Is there an option to specify bit rate in the above command.

Taken from Convert midi to mp3

2

There are 2 best solutions below

2
On BEST ANSWER

Option placement matters with ffmpeg. You're attempting to apply an output option to the input.

ffmpeg [input options] input [output options] output

Corrected command:

fluidsynth -T raw -F - sound_font_file.sf3 input.mid | ffmpeg -y -f s32le -i - -b:a 192k output.mp3

Fore more info about MP3 encoding with ffmpeg see FFmpeg Wiki: MP3.

1
On

Use timidity and ffmpeg

sudo apt-get install timidity

sudo apt-get install ffmpeg

If I have the file honorthyfather.mid you can choice

For midi to mp3

timidity honorthyfather.mid -Ow -o - | ffmpeg -i - -acodec libmp3lame -ab 320k honorthyfather.mp3

For more quality use WAV

timidity honorthyfather.mid -Ow -o - | ffmpeg -i - -acodec pcm_s16le honorthyfather.wav

For quality same WAV but low size use FLAC

timidity honorthyfather.mid -Ow -o - | ffmpeg -i - -acodec flac honorthyfather.flac