Sign In

    Enjoy FOSSwire's content? Have it delivered! Subscribe

    Using ffmpeg to convert to MP3

    Now we all know we should be using free and open formats like Vorbis for our audio, right? Yeah. Unfortunately, sometimes we are restricted by what some devices will support.

    If you've got some tracks in Vorbis, WAV or another format and you want to convert it to MP3 format. Now you can use the open source MP3 library LAME, but it doesn't support quite as many input formats as ffmpeg does.

    ffmpeg, for the uninitiated, is a piece of software (and software library) designed for converting all sorts of audio and video from one format to another. Most distributions don't ship it manually and many don't support it, so you may need to enable extra software repositories before installing the ffmpeg package.

    Once you've got that, converting an audio file should be pretty easy and works as follows. Remember ffmpeg does take quite a lot as input files, and will detect the input format automatically. In a similar vain, the output format will be automatically determined by the file extension you give, so it makes light work of conversion and avoids lots of confusing command line switches.

    A simple audio convert might be:

    $ ffmpeg -i file file.mp3

    Substitute in your filename, make sure the .mp3 extension is intact in the output filename and a convert should happen. Obviously, doing like this does have the disadvantage of using default settings.

    The simplest of these settings to alter would be the bitrate, which determines the output quality. For MP3, a really quick guide would be that 128 kbps is fair quality, 160 kbps is good quality and 192 or above is very good quality.

    Setting the bitrate of the output file is also simple, so let's add it to the command:

    $ ffmpeg -b 192k -i file file.mp3

    Here I set for 192 kbps quality.

    This is only a very basic quick starter, but it does show you how easy it is to start converting audio with ffmpeg. If you need more flexibility in your conversion, you may want to switch to a solution like LAME, but for the ease of use and wealth of input formats a well-configured ffmpeg installation can give you, it's well worth a try for your converting needs too.


    Avatar for peter Peter Upfold - http://peter.upfold.org.uk/

    Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Ubuntu on his white MacBook, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things.


    Tagged in

    • FSDaily

    Home » Articles »

    Discussion: Using ffmpeg to convert to MP3

    1. Marcos (guest)

      # Posted on 02 November 2007 at 10:49 PM

      Or just use PyTube as GUI ;)

      http://www.bashterritory.com/pytube

       

    2. Xiong Chiamiov (guest)

      # Posted on 15 May 2008 at 06:35 PM

      Actually, the command goes more something like this: $ ffmpeg -i [input] -ab 192k [output.mp3] Not only is the -b flag only for video, but you have to put the output options inbetween the input file and the output file.

       

    3. youtube downloader (guest)

      # Posted on 02 July 2008 at 05:07 PM

      when converting an FLV to MP3, the FLV is 4 mins long but the mp3 is 20 mins long, do you know the solution?

       

    4. Drew (guest)

      # Posted on 10 November 2008 at 02:41 AM

      Thanks to the help I got here and from other blogs, I've made the conversion command accessible from the context menu. So I can right-click an m4a and convert it to mp3. It comes out like Joe - His Song.m4a.mp3 but that's ok with me. This is for Windows XP.

      Go to tools>folder options>file types> and find the m4a extension. Go down to advanced and make a new action. I call mine "convert to mp3" . . . uh yeah.

      For the "application used to blah blah blah" paste in "C:Program FilesWinFFffmpeg.exe" -i "%1" -ab 160k "%1".mp3

      I bet there's a way to strip out the m4a part of the filename, but it'll be good down the road when I can look at the name and say, "Oh yeah, these are all the files I scammed off so and so."

      Have fun.

       

    5. Shankar Prasad (guest)

      # Posted on 16 June 2009 at 07:41 AM

      Is it possible to convert .rm(real media) files to mp3 using ffmpeg? If yes, how can I do that?

       

    6. davandg (guest)

      # Posted on 17 June 2009 at 12:27 PM

      ffmpeg - formats to know formats that support your ffmpeg.

      ffmpeg is very easy to use, just do : ffmpeg -i inputFile.rm outputFile.mp3 and its done. You can add many options, use : ffmpeg -h to know all of these.

       

    Did you like this article? Want to help write the content that makes FOSSwire great? Submit your own article and get it reviewed by other members.

    Home » Articles » Using ffmpeg to convert to MP3