Hey, Would you like to work at Home ?? Just click here No need to pay, just register free and activate your account and get data Entry Work at your Home.

Tuesday, January 22, 2008

Converting Audio/Videos using FFMPEG

I was simply ignoring writing this articles but after writing articles on Installing FFMPEG on Linux i couldn’t resist on writing this article. Anyways this article will guide you on how you can convert audio video formats using FFMPEG.



This articles in divided in various sections



  • Parameter Used

  • Command Line Syntax

  • Conversion Examples


Parameter Used:

Common Parameters

















-i ‘filename’ Filename will be the Path of Source Filename
-y Overwrite the existing output file without prompting
-an disable audio

Video Related Parameters





















-aspect ‘aspect ratio’ Set Aspect Ratio for the video (4:3, 16:9 or 1.3333, 1.7777)
-r ‘rate’ set frame rate in Hz for the video
-s ’size’ set video resolution size (Width x Height)
-sameq use same video quality as source

Audio Related Parameters





















-ar ‘rate’ set audio sampling rate (in Hz)
-acodec ‘codec’ force audio codec E.g. mp3
-vol ‘volume’ change audio volume (256=normal)
-ab ‘rate’ set audio bit rate (in bits/s)

Advanced Parameters









-map_meta_data output file:input file Copy the Metadata from Input File to Converted output file

Command Line Syntax

ffmpeg –i ‘input filename’ ‘output filename’



  • Syntax Example:

    [root@linux /]# ffmpeg -i demo.mpg demo.flv

    Here FFMPEG will convert demo.mpg file to demo.flv


Conversion Examples:


Video Examples:



  • Converting MOV to FLV using FFMPEG

    ffmpeg -i movie1.mov movie1.flv

    This will convert movie1.mov file to movie1.flv



  • Converting Mpeg to FLV using FFMPEG

    ffmpeg -i movie1.mpeg movie1.flv

    This will convert movie1.mpeg file to movie1.flv



  • Converting AVI to FLV using FFMPEG

    ffmpeg -i movie1.avi -s 500×500 movie1.flv

    This will convert movie1.avi file to movie1.flv and will resize the video resolution to 500×500



  • Converting 3GP to FLV using FFMPEG

    ffmpeg -i movie1.3gp -sameq -an movie1.flv

    This will convert movie1.3gp file to movie1.flv and will keep the original file settings and will disable the audio content


Audio Examples:



  • Converting aac to mp3 using FFMPEG with MetaData

    ffmpeg -i audio1.aac -ar 22050 -ab 32 -map_meta_data audio1.mp3:audio1.aac audio1.mp3

    This will convert audio1.aac to audio1.mp3 having audio rate 22.05 Khz and Audio BitRate 32Khz and will copy the meta data from .aac file to .mp3 file



  • Converting WMV to MP3 using FFMPEG

    ffmpeg -i audio1.wmv audio1.mp3

    This will convert audio1.wmv file to audio1.mp3



  • Converting WMV to FLV using FFMPEG

    ffmpeg -i audio1.wmv audio1.flv

    This will convert audio1.wmv file to audio1.flv, this will generate only audio content



  • Converting AMR to MP3 using FFMPEG

    ffmpeg -i audio1.amr -ar 22050 audio1.mp3

    This will convert audio1.amr file to audio1.mp3 having audio rate 22.05 Khz



  • Converting aac to mp3 using FFMPEG

    ffmpeg -i audio1.aac -ar 22050 -ab 32 audio1.mp3

    This will convert audio1.aac to audio1.mp3 having audio rate 22.05 Khz and Audio BitRate 32Khz

Installing FFMPEG on Linux


FFMPEG is an open source application that allows you to convert video and audio files easily between a variety of different formats. It supports most industry-standard codec and can convert from one file format to another quickly and easily. This article will guide you to installing FFMPEG and other codec on Linux.



FFMPEG Installation Requirements:

  • FFMPEG

  • LAME Mp3 Audio Codec (Requred for mpg, flv, avi, wmv etc files)

  • AMR Audio Codec (Required for 3gp video files)

  • XVID Audio Codec

  • FFMPEG-PHP


Note on installing FFMPEG:



  • All the Audio Codec getting used in FFMPEG are not part of FFMPEG Source base


FFMPEG Download URL:

On the download page of FFMPEG they have geven the download link from SVN and checkout-snapshot but i would suggest to use SVN source code base.

FFMPEG Download Page FFMPEG

The url for the SVN source code for FFMPEG is: svn://svn.mplayerhq.hu/ffmpeg/trunk


To download from SVN you will have to install subversion located at subversion.tigris.org, or you can use “TortoiseSVN” located at tortoisesvn.tigris.org.


LAME Mp3 Codec download URL: Lame Mp3 Codec


AMR Audio Download URL: AMR Audio Codec

To install the AMR codec you will require both AMR-WB and AMR-NB files.


XVID Audio Download URL: XVID Audio Codec


FFMPEG-PHP Download URL: FFMPEG-PHP


Installation Steps:

It is a good practice to install all the external audio codec libraries first and then install the FFMPEG.


Installing LAME MP3 Encoder



  • Untar the lame file by using tar zxvf lametarfile

  • Assign 777 permission rights to the lame folder by typing chmod 777 lamefolder -R

  • Traverse to the root of lame folder and type

    ./configure

    make

    make install


Installing AMR Codec

For installing the AMR codec there are two separate files that needs to be installed are AMR-WB and AMR-NB.



  • Untar the AMR file by using tar zxvf tarfile

  • Assign 777 permission rights to the amr folder by typing chmod 777 amrfolder -R

  • Traverse to the root of amr folder and type

    ./configure

    make

    make install


Note on Installing AMR:

You might get errors installing AMR codec on Autoconf utility of linux. To resolve this problem will have to install the latest version of Autoconf utility from Download AutoConf


Installing Xvid Codec



  • Untar the xvid file bu using tar zxvf tarfilename

  • Assign 777 permission rights to the lame folder by typing chmod 777 xvidfolder -R

  • Traverse to the root of xvid folder

  • Goto Build/generic folder and type

    ./configure

    make

    make install


Installing GCC



  • This is required only if the SVN for FFMPEG is not compatible with the existing version of GCC(3x) requires a new version for the same

  • After the installation of GCC need to convert all the files of SVN to Unix compatible by using “dos2unix ffmpegfolder/* -R”.


Installing FFMPEG



  • Download the ffmpeg from SVN

  • Assign 777 permission rights to the ffmpeg folder by typing chmod 777 ffmepgfolder -R

  • Traverse to the root of ffmpeg folder and type

    ./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –enable-libamr-nb –enable-libamr-wb –enable-libxvid –enable-gpl –enable-shared

    make

    make install


Installing FFMPEG-PHP



  • Download the ffmpeg-php from Sourceforge

  • Unpack the archive by using following command “tar -xjf ffmpeg-php.X.XX.tar.gz”

  • Iterate inside the ffmpeg-php directory

  • Run phpize (included with your php install) to build configuration files

    ./configure

    make

    make install


NOTE FOR FFMPEG-PHP:

If you are planning to install FFMPEG-PHP then will have to add –enable-shared parameter while configuring FFMPEG


You might get installation error while making the file related to html or texti files in ffmpeg\doc folder. The solution for this that worked for me is to just create a empty file by using touch command in the respective folders.


Note:

The following configure parameter will work with FFMPEG 0.49. But now the latest version does not have –enable-libogg parameter so if you are planning to installing the latest version then the configure parameter would be /configure –enable-libmp3lame –enable-libvorbis –enable-libamr-nb –enable-libamr-wb –enable-libxvid –enable-gpl –enable-shared.


Note on Reinstalling FFMPEG:

If you are planning to reinstall the FFMPEG software the will have to perform following steps:



  • ./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –enable-libamr-nb –enable-libamr-wb –enable-libxvid –enable-gpl –enable-shared


  • make clean

  • make install


Still facing problem while installing leave a comment, will try my best to help you out. :)


Related Articles on FFMPEG




Your Ad Here