FFmpeg usage command

2007-8-6 Update: Based on the my own FLV conversion knowledge, I have started a Web 2.0 service call – VCASMO. It is a video + PowerPoint online presentation platform.

Convert other video to FLV
ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv
-i input file name
-ar audio sampling rate in Hz
-ab audio bit rate in kbit/s
-f output format
-s output dimension

Convert other video to FLV with metadata
You have to install flvtool2, too, see my previous post
ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 - | flvtool2 -U stdin video.flv

Convert FLV to jpg sequence
ffmpeg -i video.flv -an -r 1 -y -s 320x240 video%d.jpg
-i Input file name
-an disable audio
-r fps
-y overwrite file
-s output dimension

Convert particular frame to jpg
ffmpeg -i video.flv -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 320x240 video%d.jpg
-ss record start time
-t record end time last for
So if you want to save frame 4 (00:00:04) -ss 00:00:03 -t 00:00:01. Note: it is count from 00:00:00. Even you want to save one jpg, you still need to use %d for naming, it is strange that I grab one frame for one second, it will return two identical jpg files for me

Related Article

Other Reference

68 replies on “FFmpeg usage command”

  1. Hey yeah I found that the “ar 22050” is the really important part when dealing with flvs. I made a c# service which listens to a mailbox and picks up the video files and adds them to a website, works really nicely.

  2. I’ve been using ffmpeg to grab frames using the following syntax, it doesn’t require the %d in the filename.

    ffmpeg -i input.flv -an -ss 00:00:01 -r 1 -vframes 1 -s 400×300 -f mjpeg -y output.jpg

  3. ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320×240 video.flv

    Hi all,
    The above coding is converting .avi to
    .flv file but the .flv file is not running. I dont know the reason. Any one can help me

  4. Hi all,

    I am trying to convert .avi video to flv using the command

    ffmpeg -i football.avi -ar 22050 -ab 32 -f flv -s 320×240 – | flvtool2 -U stdin video.flv

    I installed all the steps which was mentioned in http://luar.com.hk/blog/?p=669

    I am getting the error, while running the above command. So please can any one help me rectify the error.

    Error was:

    Input #0, avi, from ‘football.avi’:
    Duration: 00:00:22.0, bitrate: 261 kb/s
    Stream #0.0: Video: msmpeg4v1, 224×160, 25.00 fps
    Stream #0.1: Audio: pcm_s16le, 8000 Hz, mono, 128 kb/s
    Output #0, flv, to ‘pipe:’:
    Stream #0.0: Video: flv, 320×240, 25.00 fps, q=2-31, 200 kb/s
    Stream #0.1: Audio: mp3, 22050 Hz, mono, 32 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #0.1 -> #0.1
    Press [q] to stop encoding
    /usr/local/lib/site_ruby/1.6/1.6/flvtool2/base.rb:280:in `create_directories_for_path’: undefined method `inject’ for # (NameError)
    from /usr/local/lib/site_ruby/1.6/1.6/flvtool2/base.rb:198:in `process_files’
    from /usr/local/lib/site_ruby/1.6/1.6/flvtool2/base.rb:44:in `execute!’
    from /usr/local/lib/site_ruby/1.6/1.6/flvtool2.rb:168:in `execute!’
    from /usr/local/lib/site_ruby/1.6/1.6/flvtool2.rb:228
    from /usr/bin/flvtool2:2:in `require’
    from /usr/bin/flvtool2:2

    Any one help me.

  5. I’m using ffmpeg to convert to FLV, but for some reason there is no sound in the output file. I’m using this command:

    ffmpeg -i file.avi -ar 22050 -ab 32 -f flv -s 320×240 file.flv

    Which yields this output:
    FFmpeg version SVN-r6147, Copyright (c) 2000-2004 Fabrice Bellard
    configuration: –cc=gcc-3.3 –enable-shared –enable-pthreads –disable-vhook
    libavutil version: 49.0.0
    libavcodec version: 51.12.0
    libavformat version: 50.5.0
    built on Sep 1 2006 12:29:40, gcc: 3.3 20030304 (Apple Computer, Inc. build 1819)
    Input #0, avi, from ‘brad.avi’:
    Duration: 00:00:06.1, start: 0.000000, bitrate: 2172 kb/s
    Stream #0.0: Video: mjpeg, yuvj420p, 320×240, 17.04 fps(r)
    Stream #0.1: Audio: pcm_s16le, 22050 Hz, mono, 352 kb/s
    File ‘brad.flv’ already exists. Overwrite ? [y/N] y
    Output #0, flv, to ‘brad.flv’:
    Stream #0.0: Video: flv, yuv420p, 320×240, q=2-31, 200 kb/s, 17.04 fps(c)
    Stream mapping:
    Stream #0.0 -> #0.0
    [flv @ 0x1283008]removing common factors from framerate
    Press [q] to stop encoding
    frame= 105 q=7.6 Lsize= 235kB time=6.2 bitrate= 313.0kbits/s
    video:234kB audio:0kB global headers:0kB muxing overhead 0.770648%

    Any help is appreciated!

  6. Yay! So many sources on the net for grabbing a single frame using ffmpeg and none of them work, yours does!

    Thank you!

  7. ffmpeg -i video.flv -an -ss 00:00:03 -t 0.001 -r 1 -y -s 320×240 video.jpg

    will make only one frame and you wont need %d

  8. First let me tell you …

    You guys simply rock…

    Still everyone have problem converting video using ffmpeg with audio.. I thought I would share my expertise in this problem…

    First of all .. I am using windows server it might be little different for some of you guys..

    but this is what commands you can use… in sweet PHP

    But before you use this command .. you need to download riva encoder under windows.. install it on your system (once you install it copy two files into plugin directory)or may be just extract two files out of installer called ffmpeg.exe and flvtool2.exe and then copy it under your webserver or somewhere behind your webserver root directory.. and just simply call it through your php file..
    You can simply use precomplied files for your linux OS and then store it under the path and use it as a shell command…

    This command is same as c or c++ exec

    For those we are using this first time.. It is basically use to run executable files under any operating system.. On windows exe and on linux a.out…

    Under windows..

    // First command will convert video to flv format .. and also include audio to it…

    exec(“path to /plugins/ffmpeg-win32/ffmpeg/ffmpeg -i path to input/brachial/TheKnack.mpg -b 500 -r 25 -s 320×240 -hq -deinterlace -ab 56 -ar 22050 -ac 1 path to output/brachial/TheKnack.flv 2>&1”, $output);

    // This command will add meta tags to the flv files using flvtool2..

    exec(“path to/plugins/ffmpeg-win32/ffmpeg/flvtool2 u path to in and same output file/brachial/TheKnack.flv 2>&1”, $output);

    foreach($output as $outputline){

    This will have both audio and meta tags into converted FLV file…

    If you still have any problem regarding this please contact me through email aniketmehta at yahoo dot com and i will be happy to help you with this…

    Aniket Mehta.

    To solve audio problem, you need to compile ffmepg with required audio codes.. Under windows riva already have this done for you…

    Remember this is just for research or study purpose.. No other intention is explicitly expressed or implied.

  9. Amazing tutorial, really much more than i expected, but there is a sound (audio codec) problem i had encountered;

    [root@roxxi ffmpeg]# ffmpeg -i paris.avi -ar 22050 -ab 32 -f flv -s 320×240 paris.flv
    ffmpeg version 0.4.9-pre1, build 4718, Copyright (c) 2000-2004 Fabrice Bellard
    built on Apr 5 2007 17:13:13, gcc: 3.4.6 20060404 (Red Hat 3.4.6-3)
    Input #0, avi, from ‘paris.avi’:
    Duration: 00:00:05.3, bitrate: 2386 kb/s
    Stream #0.0: Video: mjpeg, 320×240, 15.00 fps
    Stream #0.1: Audio: pcm_u8, 11024 Hz, mono, 88 kb/s
    Output #0, flv, to ‘paris.flv’:
    Stream #0.0: Video: flv, 320×240, 15.00 fps, q=2-31, 200 kb/s
    Stream #0.1: Audio: 0x0000, 22050 Hz, mono, 32 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #0.1 -> #0.1
    [flv @ 0x8219388]removing common factors from framerate
    Unsupported codec for output stream #0.1

  10. well, my problem is solved after i download ffmpeg from svn.

    a little advice:
    don’t use ffmpeg 0.4.9. pre1 for the version, seems to be old and has some audio codec problems.

  11. Yes, this is fantastic. I do have one question, when I convert to flv how to get the best quality? The quality of the flv’s is not good at all, am I doing something or not doing something I should or should not be?

    Did I say this is fantastic? Thanks.

  12. Just thought id mention that when setting the -b option, it needs it in bit/s – so for an flv to be saved at 512kb/s, you need to use ‘-b 512000’…

    Took me a while to notice this in the documentation and I was really confused why my vids were always really low quality.

  13. javaid use -t 00:00:30

    `-t duration’
    Set the recording time in seconds. hh:mm:ss[.xxx] syntax is also supported.

    `-fs limit_size’
    Set the file size limit.

  14. Hi,
    I want to convert .avi to .flv
    For that i have used following commandline

    ffmpeg -y -i “Video.avi” -r 5 -b 512000 -g 15 -ar 44100 -ab 224k -f flv “Video.flv”

    My problem is that the video quality of “video.flv” is not same as “video.avi”.

    plz note that video.avi is screen captured video(The current activity of desktop)and resolution is current system’s resolution(i.e 1024×768)
    Image in my output FLV file is blurred(Text is not clearly readable,but picture quality is good).

    Can anyone help me in this regard?
    Which parameters i should pass to FFMPEG to get better video quality?

    I have also tried with -b 2496..but there is not much diffrence.

  15. I am having the same problem as a posted above… I’m getting the following output:
    frame= 133 q=2.0 Lsize= 204kB time=5.3 bitrate= 314.5kbits/s
    video:202kB audio:0kB global headers:0kB muxing overhead 1.034389%

    Is there any way to test to see if the LAME codec installation is successful? I think that may be the issue here. Thanks in advance!

  16. Can we get jpg image from wmv file?
    Please send the code to generate jpg image of wmv file.


  17. Zehra: try increasing your frame rate -r 15 -g 30

    right now you’re doing 5fps. (-r 5)

    larger files but better clarity.

  18. Hi, When I was trying to convert video to flv, first upload and then submit, it is converting to flv fine, but during the conversion it is opening the download option for open /save /cancel, means, it is giving the output the streaming details, how Can I stop that?

    Means I want just upload and convert that by ffmpeg and it is redirecting to flash player.

    Give suggestion,

  19. Nice collection of hard to find answers!!!
    My problem concerns nellymoser codec.
    Is there a way to pump into an flv an mp3 stream (Over writing the old one) & not destroying the video??
    Cant seem to find a way to do it either using flvtool or ffmpeg
    Help is appreciated

  20. I was facing the same audio problem. Video converted without any audio. Of course we do not have lame installed but don’t ffmpeg has its own default codecs. We have not mentioned any encoder in command options.

    More over, if we download and configure lame, usr/bin, will it be detectable by ffmpeg or some thing more will be required ?

    Thanks and Regards

  21. I found this blog site very informative in regards to FFmpeg.

    I was trying to add the meta data like author, comments, title, copyright but I have to go for converting the file completely to another format instead of just setting these data in the same file.

    Any suggestions from your side will be good for me.

    I need to set the author for all formats of videos files supported by FFmpeg

  22. Hi, i want to convert various image formats(.png, .bmp, .tiff,…) to .jpg file format. how to convert using ffmpeg, or other methods… can u please tell me the solution else suggession.


  23. yes you can get jpg from wmv: do this:=>
    ffmpeg -i $uploaded_video_file_flv -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -s 320×240 -vcodec mjpeg -f mjpeg $path_to_jpg_file”;

  24. Hi all,

    I’m trying to export a frame from a list of flv. It works fine using:

    ffmpeg -i *.flv -t 00:00:15 -ss 00:00:10 -vframes 1 -s 32×24 %d.jpg

    But i want to keep the original name from the flv file for the jpg. I don’t know how to do it anyone knows how it works?

    many thanks,

  25. I often get a serious ecoder issue – some of the .avi files I send are encoded with a greyscale (no colours) and the video is leaning to the right

  26. Yay, I solved the problem with audio on Ubuntu 7.10. The trick was to add medibuntu repository and install updates. Than ffmpeg converted video with audio.

    It seems that default ffmpeg is not compiled with mp3 support.


  27. A manual to ffmpeg would be nice. I have yet to see a full manual for this wonderful program, explaining all codecs etc…(but I have found tons of homepages, asking for how to use this program)…

  28. Thanks for these nice examples. Hope you can continue to put up such good examples in the future, I am going to “bookmark” your blog 🙂

  29. Hi all,
    My project needs the audio format conversions.
    For the purpose i am using ffmpeg.exe and faad.exe.
    I am working on Windows XP, but my client’s opeating system is Open
    I just needed to know whether this ffmpeg.exe and faad.exe would work
    fine on Open Solaris also along with thier system commands.

    I am working with ruby on rails 2.0.2…

Comments are closed.