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.
flvtool2 -h

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!
18 Comments
Hi, thank you for your post! I have two small corrections (additions): The current release 1.0.6 solves almost any bug and the wiki is online again. Please help to fill it up:
http://flvtool2.rubyforge.org/wiki/wiki.pl
Ciao,
Norman
Just to correct myself: The URL of the wiki is http://osflash.org/flvtool2
Hi,Brooks
As flvtool2 can’t modify the timestamp when using the -C option. Is there any tool that could set the starting timestamp to zero or any that could merge two or more flv files to one ?
Thanks,
peterman
FLV to AVI MPEG WMV 3GP MP4 iPod Converter
(http://www.qweas.com/download/video_dvd/flash_tools/flv_to_avi_mpeg_wmv_3gp_mp4_ipod_converter.htm)
which can convert FLV file to popular video formats including AVI, MPEG, WMV, DivX, Xvid, ASF, 3GP, MP4, iPod, PSP, Zune and
convert FLV to audio formats MP3, WMA and WAV.
Großhändler
Hi, Thank you. A very nice News. THANK
Hi Folks,
I have a question reguarding the size limit of xtradata meta which can be included into FLV file. Any idea experience about that ?
I planned to include meta information about content directly into the FLV as speech transcription or subtitles or whatever. Is this way good ?
Thanks for any answer.
good to know that one view flv meta data. The only thing not cool is that one cannot get the meta data online without downloading.
Is it possible to modify metadata using XML file? Thanks for the answer
I used mencoder to create flash files, but the header is not ‘FLV’ as expected, my files have this header:’FWS’. I don’t know enough about mencoder or flash to understand the difference - is this critical?
I manually changed the header and ran flvtool again, but ran into another issue:
ERROR: bignum too big to convert into `long’
ERROR: /usr/lib/ruby/site_ruby/1.8/flv/core_extensions.rb:86:in `read’
ERROR: /usr/lib/ruby/site_ruby/1.8/flv/core_extensions.rb:86:in `read__STRING’
ERROR: /usr/lib/ruby/site_ruby/1.8/flv/stream.rb:408:in `read_header’
ERROR: /usr/lib/ruby/site_ruby/1.8/flv/stream.rb:57:in `initialize’
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2/base.rb:272:in `new’
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2/base.rb:272:in `open_stream’
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2/base.rb:238:in `process_files’
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2/base.rb:225:in `each’
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2/base.rb:225:in `process_files’
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2/base.rb:44:in `execute!’
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2.rb:168:in `execute!’
ERROR: /usr/lib/ruby/site_ruby/1.8/flvtool2.rb:228
ERROR: /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
ERROR: /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
ERROR: /usr/bin/flvtool2:2
Help please?
the -C option is not updating the metadata. can anyone tell me how can i update the metadata too. i alredy used the metadata injectors but nothing works they still show the old timestamp after cutting…. any idea…
Thanks
Hi,
how can i use the -i and -o commands? For example i have a 2 minutres video,but i just want to have the first minute. What is the correct command?
thx in advance
Sorry for the previous post..i found the right command
-C -i time -o time
thx
FLV to Ipod for beginer can try the software list here.
Hi, I tried injecting cuepoints into a FLV, followed every steps of this tutorial, but when my video plays, I get the error:
Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback onCuePoint. error=TypeError: Error #2007: Parameter definitionName must be non-null.
The problem is with the FLV, because I tested with other FLVs and the cuepoints do trigger without any error… I only get this error when I play this one.
I tried opening it in RichFLV, and the cuepoint names are indeed empty. They should be named “onCuePoint”. When I open other FLVs, they are all named onCuePoint…
How do I change the width and height?
@ Newb - check out this post:
http://www.brooksandrus.com/blog/2007/04/15/change-insert-flv-metadata-values-timestamp-dimensions-with-flvtool2/
For adding cuepoints to flv, I’m using Flash Video MX Pro. It is very easy to handle. Maybe you can have a try. Here is the link.
http://www.video-to-flash.com/video_to_flash/
Hope you enjoy it.
I tried opening it in RichFLV, and the cuepoint names are indeed empty.
3 Trackbacks
[...] Brooks Andrus » Blog Archive » Flvtool2 - Flash Video (flv) Metadata / Cue Point Injector and Cutt… (tags: flash video flv ruby) [...]
[...] And this is what you should read to know the basics: Flvtool2 from QuickWiki. Check out this blog entry for a more detailed tutorial on how each command and/or option [...]
[...] have been successful using FLVtool2 as described in this OSX-based tutorial. When I specifically need to embed named cuepoints in a video I didn’t render myself, this [...]