This is perhaps one of the most frequently asked questions on the web: you’ve downloaded a nice FLV (let me guess, from YouTube 😉 ) and you want to convert it into a MP3 to be able to play it on your iPhone or mobile phone. How to realize this? Yes, there are tons of FLV to MP3 converters and media converters on the web. But seriously, why do we need something so sophisticated whereas a simple command line will do the whole work for us? Here is my solution with a MS-DOS batch file (will only work on Windows, for the Mac solution check How to convert mp4 with Automator).

Step 1: Download a precompiled Windows version of ffmpeg

Take the correct distribution (all the ffmpeg distributions are compressed in .7z. Download WinRAR ) and go to the /bin directory and check the ffmpeg.exe. This is the only file you will need. Once extracted, you can place it in a directory of your choice or even set this path into the Windows system variables so that you can call the ffmpeg command from everywhere.

Step 2: Write a batch file to convert the flv to mp3

Sometimes old school script programming can be so cool 😉 We are going to write a MS-DOS batch file that will automatically convert the FLV files of a directory into MP3 and place these encode MP3s into a directory /encoded-files

Here is the content of the batch file:

mkdir "encoded-files"
 FOR %%X IN (*.flv) DO ffmpeg -i "%%X" -ab 256 "%%~nX.mp3"
 FOR %%X IN (*.mp3) DO MOVE "%%X" "encoded-files"

The above code is pretty straight forward: -i is used as input parameter for ffmpeg. Then we are using the –ab 256 to tell which kbit/s encoding we would like to use.

The %%~nX stuff is a MS-DOS command telling to only extract the name (of the file) parameter without the file extension. This allows us to give the correct extension (in our case *.mp3) to the encoded file.

Step 3: Launch the script and enjoy the music!

Go to a directory that contains a lot of FLV and you want to convert MP3 and launch the script! After a few seconds (depending on the power of your PC) you will have all your MP3 into the /encode-files directory.

It couldn’t be easier 😉

💬 Comments

Don't hesitate to share your comments. I'm always happy to read your input!