FLV Parser

Read, Write, Parse, Stream and manipulate meta tags in FLV Containers on the fly

  • Language: ActionScript
  • Released: Jun 2, 2011
    Last Update: Feb 16, 2014

The FLV Parser makes use of the NetStream.appendBytesAction and NetStream.appendBytes methods to pass the parsed FLV tags from the ByteStream.

When a NetStream object enters "Data Generation Mode" you can write your own video / audio / meta tags to the stream.

The FLV class makes it possible by providing several methods for manipulating meta tags:

WriteMetaTag(object:Object, event:String='onMetaData')
WriteTag(type:int, body:ByteArray, timestamp:uint=0, timestampExt:uint=0, streamId:uint=0)
GetTagsOnTime(time:Number) : Array
MergeFLV() : ByteArray
Clear() : void
Destroy() : void

In addition the FLV class takes care of all the usual NetStatus events, so you can use the constructed NetStream object as any other.



FLV Class


isComplete - indicates the buffer, if full = true, else = false clearBufferOnComplete - clears the flv buffer when parsed header - ByteArray tags - Array of FLVTag objects


Seek(time:Number) : void

Seeks the buffer to the specific time in seconds

GetTagsOnTime(time:Number) : Array

Returns an array of tags after a specific time (use for seeking)

UpdateBuffer(buffer:IDataInput) : Array

Updates the FLV buffer and returns the parsed tags (use for progressive streaming)

WriteHeader(flags:int=0) : ByteArray

Writes the FLV header bytes and returns a FLVHeader object

WriteMetaTag(object:object, event:String='onMetaData') : ByteArray

Writes a meta data tag to the stream and returns a FLVTag object

WriteTag(type:int, body:ByteArray, timestamp:uint=0, timestampExt:uint=0, streamId:uint=0) : ByteArray

Writes a FLV tag to the stream and returns a FLVTag object

MergeFLV() : ByteArray

Returns a merged version of all FLV tags as 1 ByteArray

Complete() : void

Call this method when progressive streaming is finished

Clear() : void

Clears the buffer, header and all data consisted in the class

Destroy() : void

Clears and null all data



import com.ivoyankulovski.FLV.FLV;
import flash.net.NetStream;
import flash.net.NetConnection;
import flash.net.URLStream;
import flash.events.ProgressEvent;
import flash.events.Event;
import flash.media.Video;
import flash.utils.setTimeout;

* Remote FLV Streaming
* Uses 1 ByteArray to parse and construct two different NetStream objects

function CreateFLV() : Object
    * Enter Data Generation Mode

    var connection:NetConnection=new NetConnection();
    var netStream:NetStream=new NetStream(connection);

    * Config NetStream

        onMetaData:function(data:Object) : void{


    * Create the FLV Instance
    var flv:FLV=new FLV(netStream);

    * Create a video object to render the video

    var video:Video=new Video();

    return {flv:flv, video:video, netStream:netStream};

var container1:Object=CreateFLV();
var container2:Object=CreateFLV();

var delay:Number=1000;

* Create a URLStream object to parse as ByteArray

var urlStream:URLStream=new URLStream();
urlStream.addEventListener(ProgressEvent.PROGRESS, onStreamProgress);
urlStream.addEventListener(Event.COMPLETE, onStreamComplete);
urlStream.load(new URLRequest('sample.flv'));

function onStreamProgress(event:ProgressEvent) : void
    var tags:Array = container1.flv.UpdateBuffer(urlStream);
    setTimeout(function () : void{
        var tag:ByteArray;
        var l:int=tags.length;
        var remoteTag:ByteArray;
        for(var i:int=0;i
You need to log-in or create an account
  • Create an account
  • Log-in
Please use your real name.
Activation link will be sent to this address.
Minimum 8 characters
Enter your password again

Clicking this button confirms you read and agreed to the terms of use and privacy policy.


Save your watchlist

Fill your details below to receive project updates from your watch list - including new versions, price changes and discounts.

I agree to the terms of use and privacy policy.

1 license From » FREE 14 day money-back guarantee View Licenses
or Get a quote

for customization or integration services

  • This code is very well done. I have looked to @thibault_imbert in the past for his expertise with video in Flash. This functionality is not available anywhere else.
    TS Tony Sherritt
    1 year ago, 0 comments
    Was this helpful?
    Flag 1 of 1 people found this review helpful
Post a comment

Or enter your name and Email
No comments have been posted yet.