FLV Parser

Released 4 years ago , Last update 10 months ago

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

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:

UpdateBuffer(buffer:IDataInput)
WriteHeader(flags:int=0)
WriteMetaTag(object:Object, event:String='onMetaData')
WriteTag(type:int, body:ByteArray, timestamp:uint=0, timestampExt:uint=0, streamId:uint=0)
Seek(time:Number)
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.

4.0
  • 5 0
  • 4 1
  • 3 0
  • 2 0
  • 1 0
1 Reviews Read Reviews

Pricing

FREE

BSD license

The BSD license is an open-source license.

Documentation

FLV Class

Properties:

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

Methods:

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

Example

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();
    connection.connect(null);
    var netStream:NetStream=new NetStream(connection);
    netStream.play(null);

    /*
    * Config NetStream
    */

    netStream.client={
        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();
    addChild(video);
    video.attachNetStream(netStream);

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

var container1:Object=CreateFLV();
var container2:Object=CreateFLV();
container2.video.x=400;

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
1 license From » FREE View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


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