I’m a couple of years late to this party, but there’s a neat Ruby based tool, Flvtool2, which allows you to stamp metadata in flv files, insert cue points–both navigation and event, and allows you to slice and dice an flv file based on defined in and out points (kudos to Norman Timmler for writing this app and making it available to the community).
Unfortunately, the documentation for this tool is almost non-existent – SPAM apparently took down the wiki. Another problem, I encountered at least, is that the builds available from RubyForge contain bugs. Fortunately, you can download the source from svn where the bugs appear to be fixed.
Since the documentation is so sparse I thought I’d post some example usage where the search bots might possibly find it.
If you wish to insert onCuePoint events into your flv, Flvtool2 accepts an xml / yaml file that declares the cue point data. The screen shot below illustrates how you can insert both “event” and “navigation” cue points. Navigation cue points should theoretically corresponds to a keyframe stamp so that an flv seek action can be assured of starting from the given timestamp.
You can view a list of of the possible commands by typing the following in your commandline shell.
To simply print out all of the metadata for a given flv simply use the following command.
flvtool2 -P some.flv
To insert cue points declared in the tags.xml file use the -A command with the -t switch. In the example below I’ll actually chain a few commands together (Add, Print, Update). The -P prints the metadata from the given file to stdout and the -U updates the flv with an onMetaTag event.
flvtool2 -APUt tags.xml src.flv output.flv
Here’s what running the proceeding code might look like.
The next example illustrates how to carve a new flv that’s four seconds long from the source flv based on in / out timestamps in milliseconds. To do this use the -C command along with the -i / -o switches.
flvtool2 -Cio 1000 5000 src.flv splice.flv
If you are interested in using flvtool2 as part of an automated ant build script you’ll need to invoke Ruby via the exec task, pass in flvtool as the ruby application to run and then pass in the desired commands, switches and arguments. The screenshot below is an example of this in action.
So there are just a ton of applications for a tool like this for both client and server-side applications which should be obvious to just about everyone likely to read this post. If you’re bored, it’s also extremely interesting to to take a peek at the metadata injected by various commercial encoders or video sharing sites (gootube et al). Enjoy!