2
votes

I'm streaming data from a server and passing it into a net stream in data generation mode. I'm successfully wrapping H264 and PCMU to be played back through NetStream, however I need to be able to capture this output from the video display it's on and store it in an image. When using an RTMP server, I'd configure it to send an RtmpSampleAccess command, with true,true for audio and video access allowed. When using RTMFP I'd do the same, send() a RtmpSampleAccess true,true from the peer to allow access.

I believe I need to send in an FLV tag for a script data object to represent the RtmpSampleAccess command, however I can't find any information on what the format of that tag needs to be. I've tried using the OSMF FLVTagScriptDataObject with the objects set to the following combinations:

["|RtmpSampleAccess", true, true];
["|RtmpSampleAccess", [true, true]];

And various attempts at guessing the naming for object parameters (though looking at the protocol docs, I'm not sure there is one).

Could someone out there help me here, would be much appreciated.

1
So you are able to make audio and video tags and append them to play the video, fine? All you need is how to draw the video container? Just trying to visualise where RtmpSampleAccess comes into play with appendBytes method.VC.One
Yep the video is rendering to a Video element, but I want to copy that to a BitmapData, and can't because the videoSampleAccess is false. In other cases I'd send this "special" message to enable that sample access.Kevin Glass
Try my answer. That's one of two methods I know to draw appendBytes video without error. Infact, it cancels all security errors!! Let me know if it works since this is shorter & less limited (than possible second option).VC.One

1 Answers

1
votes

Where you put your Netstream into Data Generation mode you add a second Play command. The second one simply plays "a blank" and for some reason this overrides the security error.

ns.play(null);
ns.play(""); //works to avoid all security errors
ns.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);

Then to draw just setup a button to run the draw_VideoFrame function when clicked, or try real-time drawing with something like below (using enterFrame):

vid_Obj.addEventListener(Event.ENTER_FRAME, draw_VideoFrame);

and then create a function like this example.

function draw_VideoFrame (e:Event) : void
{
    vid_BMD.draw( vid_Obj ); //draw into a BitMapData variable
}