Thursday, August 07, 2008

FFMpeg Settings for Flash Video

Flash Video is currently the best format to share your videos on the web. Sites such as You Tube, Vimeo, and Myspace all use the .flv format to deliver videos to the end user.

Some of the latest versions of video editing software have included .flv as an export option, however if you are using a free or cheaper option like Imovie, Windows Movie Maker or Final Cut Express then you will need third party software to get the desired .flv file format.

There are hundreds of products out there that can so this for you, for a small fee, however as with all good things on the web the best tool is free.

You can download FFMpeg from http://ffmpeg.mplayerhq.hu/

The FFMpeg settings that I use for Flash Video are listed below......

/opt/local/bin/ffmpeg -i /Users/justinavery/Movies/name_of_sequence.mov -qscale 10 -r 15 -s 720x540 -ar 44100 /Users/justinavery/Movies/name_of_flash_squence.flv

There are multiple options to choose from in FFMpeg, but I try and keep it as simple as possible.

Let's break this down into simpler terms.

/opt/local/bin/ffmpeg

The first part calls the application. You will see a lot of articles on the web that just start out with ffmpeg, but I've had some issues getting that to consistently work so have chosen to use the full path.

- i /Users/justinavery/Movies/name_of_sequence.mov

The - i is where you define the location of the movie that you are encoding to a flash flv file. As a quick way to get the location try using the tab key as you are typing the file path...... if there is a matching name of the file name will automatically be printed.

-qscale 10

This has to do with the quality of the video and the final bit rate. Previously I guessed a bit rate for the video I was encoding, or entered a maximum file size however I usually had to tweak it a few times before the flash video was to my liking. The -qscale ranges from 1 - 25 with 1 being the best quality and 25 the worse.

-r 15

This defines the frame rate, or the number of video frames that are produced each second. Generally PAL works in 25fps and NTSC works in 29.97fps, but as long as your footage doesn't involve fast moving action or quick pans you should be able to set it at 15 without noticing much loss of quality. Obviously, the less frames per second the smaller the file will be.

-s 720x540

As you can probably guess from the look of this, -s is the setting for the size of the video. The camera I use most often now is the Canon HV20 which outputs a whopping 1920x1080, so I need to scale it down to be suitable when previewing. Remember, most people won't be running HUGE screen resolutions so make sure you're not using valuable file size only for the video not to display on the screen.

The setting 720x540 is set for wide screen, but play around with it depending on the layout of your site or your target audience.

-ar 44100

Can you hear me? Well without this you run the risk of your audio content being to high or too low. 44100 is the highest, and most of my footage includes an audio track or musicians playing so I try to keep it that way. If audio isn't important to your clip then halve the number, 22050, halve again for less quality etc etc until you get the desired result.

If you're not good at maths and halving proves tough don't be alarmed, the application will alert you that your audio bit rate is not compatible and give you a list of options you can use.

/Users/justinavery/Movies/name_of_flash_squence.flv

To finish off the command we need to tell FFMpeg what to call the video and where to put it. Keep the name without spaces, use an underscore as I have done if you want to make it more readable.

Now this is by no means a be all and end all explanation on using FFMpeg to produce flash .flv files, but it's a start that will get you going and allow you to further investigate options that will suit you.

My next task will be to include the exact frame that I would like to export as the preview thumbnail for my video listing pages.

8 comments:

Chris said...

Hey man great tutorial. Simple and to the point. Cheers!

CJ

ck said...

Just a little nitpick, NTSC video is 29.97fps.
Nice article, thanks.

Anonymous said...

"The -qscale ranges from 1 - 25 with 1 being the best quality and 25 the worse." This is incorrect. The scale is 1-31. The information presented on this web page is much better explained on ffmpeg's own web site. Sorry. http://ffmpeg.org/ffmpeg-doc.html

Anonymous said...

"Flash Video is currently the best format to share your videos on the web." This is extremley incorrect. There are many many better video formats to share your video on the web. Flash Video cannot come close to the quality of video shared by some other formats. With that being said, Flash Video is most certainly the most popular, and it is very effiecient being low bandwidth (less quality).

Unknown said...

Thanks for your posts, 1-25 used to be the old settings for FFMPEG but you're right, head over to FFMpeg Official Documentation

Unknown said...

"Flash Video is currently the best format to share your videos on the web." This is extremley incorrect.

Very true! 2 Years ago when I wrote this article Flash was the leader in video, however I would now be recommending that you stick with flv, but also include OGG, MP4, and possibly also WebM.

AND, start using the < video > tag in HTML5

KeithHopkin said...

I don't get it. So many people use ffmpeg. Can somebody just format that damn doc so it's easier to read and browse??? somebody??!!

Unknown said...

I still get loads of hits from searches on this topic.

maybe you could create a site with easy to use instructions?