FLV Duration Until very recently the flv format (Flash's Streaming/Progressive video) didn't contain meta-data when exported. This meant that developers had no way of accessing basic information such as the duration of the video file.
This has been particularly troublesome for developers wishing to create progressive video applications using NetStream, NetConnection and the Video class (users of Flash Communication Server could use server-side actionscript to determine the duration for streaming applications).
note: Whilst Flash Video Exporter 1.2 is now said to automatically include 'duration' meta-data in all exported flvs I have not been able to successfully export an flv with said meta-data using the built in Sorenson encoder in Flash, but I have been able to do it using the Flash exporter plugin via QuicktimeIf Flash is your exporter of choice, or if you already have a truck load of flvs that you do not wish to re-export then don't panic; there are two (update:three!) excellent tools at hand, both of which inject meta-data in to existing flvs for you.
The first of these tools is a rather excellent
freeware application called
FLVMDI (Flash Video MetaData Injector), from the Manitu Group. FLVMDI goes above and beyond adding simple 'duration' meta-data to your file and therefore should prove to be a very valuable addition to your arsenal, even after Macromedia release any future fixes.
FLVMDI will (when possible) inject metadata about the flv's width, height, videorate, audiorate, framerate, creation date and more! It even allows you to add your own specific meta-data and generate a corresponding xml file should you wish.
Originally flvmdi was a command-line only tool, but the Manitu Group have now added a GUI interface to make it more accessible. Both FLVMDI and the GUI can be found here:
www.buraks.com/flvmdi/The next of these tools is
Flv-Duration, a
donation-ware Java app from swfx.org which has a nice simple GUI, can batch-process and recurse directories. As far as I can tell it only adds 'duration' meta-data to the files, but this is probably sufficient for most people's wishes and the batch-processing capabilities makes this a great choice for those needing to update multiple flvs. Find it here:
www.swfx.org/flv-duration/ --update (22/03/05)--
The third, and newest of these tools is FLVTool2. It works in a different way from FLVMDI in that you can insert custom meta information using custom keys, and not only under the 'xtradata' key. FLVTool2 is free to use, published under BSD license and can be run as severside application. Find it
here. The source code is also available for download.
--endOfUpdate--
Regardless of which app you choose you will be required to add a single line of code to the NetStream class in order to get access to the meta-data (C:\Program Files\Macromedia\Flash MX 2004\en\First Run\Classes). The code is as follows:
function onMetaData(info:Object):Void;
Now you can access the meta-data from within your Flash movie like this:
netStreamOb.onMetaData = function(obj){
trace(obj.duration);
}
You can read more about onMetaData and flvs in
this excellent thread from flashmx2004.com
-----------------------------------------Edit:
Here's a quick fix for a problem you may encounter when using flv's generated from .movs:
If you have created a playhead yet find that when it reaches certain points toward the end of the movie the flv stops playing (even though the end had not been reached and no onStatus event has been generated) try this fix:
//where 'totalPlayTime' is the duration metadata
if(myNS.time != totalPlayTime && myNS.time>0){
var tempTime = myNS.time;
myNS.play(theFlv);
myNS.pause(false);
myNS.seek(tempTime-1);
}
ARCHIVES

nwebb.co.uk - flash tutorials, php and more.