Convert to FLV (flash video) with ffmpeg
Wednesday April 25, 2007
First a little background on FLV.
FLV is just a container format. Primarily (back in the daze) the main video format used within was an earlier version of Sorenson.
This provides OK quality. Since then a later version (SVQ3) has superseded SVQ1, by providing the same quality at lower bitrates. Competing codecs like On2 have offered alternatives, the quality of which can be argued between by the media denizens and people that know more about it. Alternatively, go here for a great comparison.
These proprietary competitors predominantly use these newer codecs – Flix is On2’s answer to things, and Sorenson Spark (SVQ3) is the default used by Flash 8 (a variant on H.264 I’m led to believe)
While researching this, I was trying to find how to encode the video with SVQ3 on Linux. It’s beluddy complicated, because the codec is proprietary. You can use the binary version through mencoder, or so I’m lead to believe, but there are licensing issues.
To be honest, the quality/bitrate factor isn’t so much a big thing unless you’re threatened with becoming the next blood sacrifice at the end-of-the-month review if you don’t use it. Plus there’s a few remote benefits with backward compatibility, as earlier versions of flash (Flash 6) only support SVQ1…
So to use ffmpeg to convert your video (into an FLV file with an SVQ1 video stream at 200Kbit/s) the syntax is summarised:
Updated: April 2008 (see comments)
ffmpeg -i [input file options] [input file] [output file options] [output file]
ffmpeg -h (a better explanation of the options)
ffmpeg -i someVideo.avi -f flv -b 200000
someVideo.flv
A common mistake is to believe that since -b is bitrate, and video bitrate is often measured in kilobits/sec, that the argument you provide here will be indicative of KBits/sec. It’s not – always provide a value of bits per second for -b. Knocking off those last 3 zeros will have a significant impact on quality.
8 Responses to "Convert to FLV (flash video) with ffmpeg"
Apr 10, 08:00 AM
not working
Apr 10, 11:07 AM
I’ll gladly provide some guidance on this if I can – you’ll have to tell me what error messages you’re getting…
Apr 28, 12:13 PM
It works great … thx … but the -o option is not recognized. U recommend to use also the -ar 22050 option , for audio encoding compatibilities.
:)
Apr 28, 05:33 PM
Thanks trusten, things have changed in the latest version since I put this up… I’ll update the post >;)
Feb 21, 02:03 PM
$ ffmpeg -i M2U00080.MPG -f flv -b 200000 -ar 22050 mom-01.flv
FFmpeg version SVN-r17371, Copyright © 2000-2009 Fabrice Bellard, et al.
configuration: —disable-debug —enable-libfaad —enable-libfaac —enable-gpl —enable-libamr-nb —enable-libamr-wb —enable-libx264 —enable-libxvid —enable-pthreads —enable-libvorbis —enable-libtheora —enable-libgsm —enable-swscale —disable-debug —enable-shared —enable-nonfree —prefix=/usr libavutil 49.14. 0 / 49.14. 0 libavcodec 52.15. 0 / 52.15. 0 libavformat 52.29. 0 / 52.29. 0 libavdevice 52. 1. 0 / 52. 1. 0 libswscale 0. 7. 0 / 0. 7. 0 built on Feb 20 2009 07:46:45, gcc: 4.3.2 Input #0, mpeg, from ‘M2U00080.MPG’: Duration: 00:02:40.12, start: 0.220133, bitrate: 9369 kb/s Stream #0.0[0×80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s Stream #0.1[0×1e0]: Video: mpeg2video, yuv420p, 720×480 [PAR 32:27 DAR 16:9], 9100 kb/s, 29.97 tb® File ‘mom-01.flv’ already exists. Overwrite ? [y/N] yOutput #0, flv, to ‘mom-01.flv’:
Stream #0.0: Video: flv, yuv420p, 720×480 [PAR 32:27 DAR 16:9], q=2-31, 200 kb/s, 29.97 tb© Stream #0.1: Audio: adpcm_swf, 22050 Hz, 5.1, s16, 64 kb/sStream mapping: Stream #0.1 -> #0.0 Stream #0.0 -> #0.1
Error while opening codec for output stream #0.1 – maybe incorrect parameters such as bit_rate, rate, width or height
please advise…
Feb 24, 12:06 AM
The error message says it all there, you want to try playing with your options because it doesn’t like the options specified for the audio codec. Trying to force the audio rate could be giving you trouble with adpcm. Either remove it or choose a different codec, e.g. mp3 (-ac libmp3lame) could make that work…
Mar 18, 06:17 AM
Thanks for this helpful info. I’m trying to add ffmpeg support for my script and your site was the first to come up on google :-)
Mar 19, 07:28 PM
HTH :)