Tuesday, February 13, 2007

Videos don't have to tell you how long they are

There is really no surefire way to tell how long an flv is. If you search the web or post something on flexcoders someone will quickly point out that if you hook into the onMetaData handler of the stream you can get the duration of the video. How nice of them. Then you try it out and find that it doesn't work at all for you, those liars! Well, they weren't fibbing, they were just making assumptions about what you were doing. The fact is that onMetaData only works if the flv has metadata associated with it. Yes, that makes, but why wouldn't they have it set? Simple answer is no idea, I think earlier versions of flash didn't requiare it, or maybe something was used to convert the file to flash, either way it doesn't work. Fortunately there are some tools out there that will inject the metadata into the flv so that you can use that convenient onMetaData handler everyone pointed out. FLVTool2 is pretty good at this, and comes in command line and UI covered flavors. There is also a library written in Ruby that slips my mind at the moment, though I've heard it's quite good.

No comments: