Question

I'm creating an FLV via AS3 using BitmapData; the resulting flv has no audio. So I'm trying to add an audio track on top. I've converted a Sound object's bytearray into a WAV bytearray.

I'm adding on FLV headers (specifically audio headers). I'm looking through documentation (pdf here), and this is how it specifies how to write the header:

enter image description here

I'm pretty new to bytes/bits and bitwise operators, so looking at how the video header was created, I'm wondering about a few things:

When it says bit flags, does this mean that all 4 options should be combined into a bitmask? Is that what the "0x08 : AUDIO" is telling me? That it should be in a byte (base-8, right?). So to store these options, would I do something like this?

//Write byte with options: uncompressed, 44khz, 16-bit, stereo

var tag:ByteArray = new ByteArray();

tag.writeByte(0x0321);

This seems wrong, ugh.

Or can I use tag.writeByte(2) to add each option on one at a time? I've also seen tag.writeByte(2 >>> 0xff) and what-not. I'm thoroughly confused. Could anyone help, or suggest a book or write-up where I might be able to figure this out?

enter image description here

In this image when it says UB(4), UB(2), UB(1), UB(1) under type for each field, does the "UB" tell me that they should all be combined? What does the [#] mean in this situation?

I've got my work cut out for me; but any help would be greatly appreciated!

Thanks a ton

Was it helpful?

Solution

There is an open source lib to encode Flv at runtime in as3, did you tried : https://github.com/zeropointnine/leelib/tree/master/src/leelib/util/flvEncoder ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top