Tuesday, May 13, 2008

Free FLV Encoder

Today I went searching for a free tool for encoding videos (mostly AVI's) to Flash's FLV format and came up solely with Riva FLV Encoder 2. Although it's relatively old in internet years (April 2005), it worked easily for me and also displayed prominent links to the combination of programs it uses beneath the covers: FFMPEG for video conversion, LAME for audio conversion, and FLVTool2. I'm not quite sure what it uses FLVTool2 for, even after reading that site's description of it:
FLVTool2 is a manipulation tool for Macromedia Flash Video files (FLV).

FLVTool2 can calculate a lot of meta data and insert a onMetaData tag. It can cut FLV files and add cue Points (onCuePoint). A debug command lets you see inside our FLV and the print command gives you meta data information in XML or YAML format.
Perhaps it uses this simply for working with tweaking meta data within the FLV? MMPEG seems to do the heavy lifting as is evident when you try to convert an unsupported video file format like WMV which causes ffmpeg.exe to crash ...

ffmpeg.exe has encountered a problem and needs to close

The Riva application itself does not die, rather it actually tries to explain what might have happened which was a pleasant surprise.

The encoding of your video file has failed

Now FLV files simply represent video, but it is not the name of any particular encoding. Flash's video files initially used H.263 (Sorenson Spark), but Flash 8 also supports something called "On2 TrueMotion VP6" and Flash 9 allows for MPEG4 within H.264 streams. The latter two are more efficient space-wise, but more computationally expensive. I believe Riva's encoder uses H.263 exclusively, especially considering it came out right around Flash 8's release in 2005.

Wondering how to actually play an FLV in ActionScript 3, I came upon the VideoExample class in the flash.media.Video Reference. I just copied this into VideoExample.as, changed the videoURL to a FLV I encoded in the same directory, and ran it using obrunski.cmd (requires Flex 2 SDK of course) and the DEBUG option which creates a Flash Trust Configuration file temporarily so that the applet has permissions to load the file without using HTTP.

Here's the result: PlayFLV.html (download source). The movie plays right away so you'll need to refresh when it ends if you want to start over.

0 comments: