ashar_oz contact
Chief author, Open Source enthusiast, Web Programmer, and UI/UX Designer.
Friday, January 13, 2012 at 16:33

FFmpeg is a complete solution for record, convert and stream audio and video in Linux.
 
FFmpeg is OpenSource multimedia framework which has ability to decode, encode, transcode, mux, demux, stream, filter, and more of audio / video file. FFmpeg almost supports most audio/video format that currently exist, FFmpeg contains libavcodec, libavutil, libavformat, libavdevice, libswscale and libswresample and can be used by applications (3rd party application).

We pick up 10 usefull FFmpeg command that you should know, sometimes you will really need the following command when you want change/convert some audio/video format, or doing some other jobs that involve video or audio in Linux OS family.

Getting Information of video/audio file
  • ffmpeg -i video.avi
Encoding a video for iPod/iPhone (avi to mp4)
  • ffmpeg -i input_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X output_video.mp4
Encoding a video for the PSP (avi to mp4)
  • ffmpeg -i input_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac output_video.mp4
Explanations :
you can change the value of parameters given or change source file format (mpeg, flv, others), here some explanations for two command above.
    Source : input_video.avi
    Audio codec : aac
    Audio bitrate : 128kb/s
    Video codec : mpeg4
    Video bitrate : 1200kb/s
    Video size : 320px par 180px
    Generated video : output_video.mp4

Extracting Video to Mp3
  • ffmpeg -i input.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output.mp3
Convert avi  to mpg
  • ffmpeg -i input_video.avi output_video.mpg
Convert avi to gif (a moving picture)
  • ffmpeg -i input_video.avi output_gif.gif
Add some sound to a video (dubbing)
  • ffmpeg -i sound.wav -i input_video.avi output_video.mpg
Convert avi to flv (otherwise)
  • ffmpeg -i input_video.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output_video.flv
  • ffmpeg -i input_video.flv output_video.avi
Convert/Compress avi to divx
  • ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.avi
Convert avi to mpeg for dvd players
  • ffmpeg -i input_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 output_video.mpeg

Install FFmpeg in Ubuntu
You don't need to worry if FFmpeg has not been exsist in your system, you can simply install it through apt-get. you don't need to add some external repository or PPA because FFmpeg always available in default Ubuntu repository.
  • apt-get install ffmpeg