Convert Video Formats Using FFMPEG

By  on  

Getting a video into the format you like can be important when providing media to your users on the web. Unfortunately your customer or video source may not give you media in the desired format. No problem: use the FFMPEG library to quickly and easily convert your media from and to any format you'd like.

Installing FFMPEG

sudo port install ffmpegx

The above installs FFMPEG with MacPorts. The install process took quite a while because FFMPEG required that I upgrade quite a few packages. Be's worth it.

Basic Conversion Shell Script

ffmpeg -i myVideo.mpeg myVideo.flv

This is a very basic conversion directive. Since Flash video has become the standard for embedding video, I've chosen to convert to the FLV format. If you want to control more of the conversion details, grab the documentation and experiment. I've installed FFMPEG on a few websites and used PHP to direct FFMPEG to dynamically generate videos.

If you need to take control of your media, try FFMPEG. FFMPEG also has a GUI version if you prefer to avoid command line.

Recent Features

  • By
    5 Awesome New Mozilla Technologies You’ve Never Heard Of

    My trip to Mozilla Summit 2013 was incredible.  I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out.  MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...

  • By
    Chris Coyier’s Favorite CodePen Demos

    David asked me if I'd be up for a guest post picking out some of my favorite Pens from CodePen. A daunting task! There are so many! I managed to pick a few though that have blown me away over the past few months. If you...

Incredible Demos

  • By
    MooTools ContextMenu Plugin

    ContextMenu is a highly customizable, compact context menu script written with CSS, XHTML, and the MooTools JavaScript framework. ContextMenu allows you to offer stylish, functional context menus on your website. The XHTML Menu Use a list of menu items with one link per item. The...

  • By
    QuickBoxes for Dojo

    Adding to my mental portfolio is important to me. First came MooTools, then jQuery, and now Dojo. I speak often with Peter Higgins of Dojo fame and decided it was time to step into his world. I chose a simple but useful plugin...


  1. You can use WinFF, it’s an other GUI for ffmpeg with presets. It works for Linux and Windows.

  2. @Sylvain: Thanks for sharing that. I still prefer the command line — it’s faster and you can’t easily automate the GUI.

  3. I have it configured like this:
    ./configure –enable-libtheora –enable-libvorbis
    and am using the following command to create open videos for the new firefox 3.5 (3.1+) video tag:
    ffmpeg -i sourcefile_ie.wmv -acodec libvorbis -vcodec libtheora finalfile_the.ogv

    Some ffmpeg documentation:

  4. adamnfish

    Awesome, thanks David.

    If you’re on Windows, get Super. It’s a deeply ugly program, but it is awesomely powerful. Basically, it’s a GUI wrapper for a number of command line tools (including ffmpeg and others) and picks which tools to use depending on your input and output settings. Any format you’ve heard of and many you haven’t.

    Super’s websiteand here’s the actual link to the file (finding it on the website is not easy…Super setup

  5. Here is my collection of useful FFMPEG commands. I have done this for Linux – but should work on mac as well.

  6. Awesome tips Binny V A! Everyone check out Binny’s link!

  7. Wes

    For mac, I use this GUI:

  8. Vince

    Is it possible to convert to .mov?

  9. @Vince:
    I think has your answer:

    “To encode a .mov you’ll need to use the target option.”

    ffmpeg -i input.avi -target X
    Where X stands for a target type as defined in the FFmpeg docs

  10. Ronny

    I get this on my Mac: sudo: port: command not found


  11. Ronny's Concious

    @Ronny: You need to install MacPorts:

  12. sundaymicky

    You can try Cucusoft DVD and Video converters suite which includes Cucusoft Ultimate DVD and Video Converter Suite. It is the best all-in-one DVD and video conversion software converts DVDs and videos to play on almost any portable device including iPod, iPhone, Zune, PSP, video capable MP3 players, video capable mobile phones, and Pocket P.C., etc.
    You can free download this software free from here:

  13. abdulla

    I have converted video to FLV format. But the problem is File size is

    So, Am not getting any perfect solution on this. IF any one knows Pls help me.

  14. @David Walsh: I’m trying to use ffmpeg on my website to dynamically ge t thumbnails created of flv fils, but it doesn’t seem to work out that well. i have checked the and made sure its installed correctly, but i was wondering how to do this with php, every method i have found isntworking.

  15. Boyd

    Try this to create thumbnails, I have it working. You must have the GD library installed in order for this to work!

    //Only used to create an image with the same name as the video with .jpg ext
    $command="ffmpeg -i ".escapeshellarg(html_entity_decode("directory/to/video/filename"))." -an -ss ".escapeshellarg("00:00:08")." -an -r 1 -vframes 1 -y -f mjpeg ".escapeshellarg(html_entity_decode("directory/to/jpg/".$thumb."jpg"));
    //change this to your library path
    shell_exec("export LD_LIBRARY_PATH=/usr/local/lib/");
    shell_exec("nohup nice -n 1 $command > /dev/null & echo $!");

    This will create an image of the 8th second of the video

  16. Boyd

    BTW I just can’t seem to be able to convert videos I get 0Kb files, but I am able to execute the same command from the command line

    Any help would be appreciated, you can email me

  17. Ffmpeg is great for converting files but complex codec and parameters setting is often required when you are using it on linux. As far windows platform is concerned, Ffmpeg is awesome.

    • Jeff

      Thunder (or anyone), I’ve been trying to get FFmpeg working on WAMP for days. Can you please help me?

      I have found little info about installing and testing FFmpeg and flvtool2 on WAMP. I could really use someone’s help.

      I already hFFmpegmpeg, flvtool2 and FFmpegmpeg installed but I’m not sure if I have installed the correct versions of each so they all work together.

      Every test script I try gives some sort of error or I get a 0kb flv file. Maybe because the scripts are for NIX. I just don’t know.

      If someone is willing to take the time, I surappreciaterechiate it :)

      Shoot me an email:

      jeffshead at hotmail.c0m

  18. srini

    How can i convert videos in short time? guys anyone can please suggest…

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!