Monday, July 22, 2013

Turning a FLV video into an mp3 (or ogg vorbis)

I was asked a while back to take the audio off of an old flv video file and then make an mp3 out of it.

After some digging, I found a powerful yet simple to use program called FFmpeg.

Using the terminal emulator, I ran the command ffmpeg -i (name of flv file) (name of created mp3 file.)

I gave this file to the customer. A day later he said he couldn't use it, because even though the file was only 4 megabytes, the audio program he used showed it to be more than 40 minutes long.

I installed another app called Audacity, to see what the problem was.

Audacity showed it to be only 4 minutes long.

I found through some digging that the audio tracks on flv files are not ended properly.

That was ok though, thanks to Audacity and the LAME plugin.

Using Audacity I "re-created" the mp3 file, and then exported it.

This solved the open ended mp3 error, and made the track register as it's proper length, just over 4 minutes.

You can get all of these programs through the Ubuntu Software Center, Synaptic, or apt-get.
This code will install all three using apt-get: sudo apt-get install audacity lame ffmpeg

* as of the writing of this, the ffmpeg program will be replaced by "avconf" in the future. If this happens avconf should function very similarly from ffmpeg.

Windows versions can be attained for all of this software, so check the links above for more information. (The pictures.)

I'm going to now walk you through the steps with screenshots.

The first step is to enter the terminal emulator (such as Terminator, pictured here).

Then find the folder the flv file is in. In my screenshot above the flv file is named gas.flv, and it is in my /home/user directory.

Then I ran the ffmpeg command, like this ffmpeg -i gas.flv gas.mp3

This made ffmpeg take the flv file in the folder, and make a mp3 named "gas" out of it.

If I would have added ffmpeg -i gas.flv /home/user/music/gas.mp3, then ffmpeg would have put it in my music folder.

(User here means your username, for me it is /home/denny/, it is different for everyone.)

Here you can see the created mp3 file, shown via the command ls.

Now I went into my file manager (I use thunar), and right clicked the newly made mp3 file and choose "Open with Audacity".

once Audacity was opened I clicked on edit, and then "select all". I then went to "file" and  then chose "export selection".

I was then given the option to choose my format. I chose mp3 for the customer, but you can choose wav, ogg vorbis and other formats. 

I was then given this screen, where I filled in the tag info. This is an option, not necessary.
If you don't do this however, you will not see this information on audio programs or cd/mp3 players.

No comments:

Post a Comment