Highlighted

Using StageVideo and Stage3D in AIR - BETA

Adobe Employee ,
Aug 05, 2014

Copy link to clipboard

Copied

We're planning on introducing a new ActionScript feature that will allow hardware accelerated video to be used as a source texture in a Stage3D environment.  Currently, using video with Stage3D requires the use of the Video object, which is not accelerated, and manipulation of the bitmap representations of the video frames.  The planned feature, called VideoTexture, will allow direct access to a texture object that is sourced from a Netstream or Camera object.

The following sample code demonstrates the use of the VideoTexture object.

1) Create a VideoTexture object and attach a NetStream (or Camera) object to the VideoTexture object:

var ns:NetStream;

var context3D:Context3D;

var texture:VideoTexture;

texture = context3D.createVideoTexture();

texture.attachNetstream(ns);

ns.play("video.3gp");

texture.addEventListener(VideoTexture.RENDER_STATE, renderFrame);

2) A texture representation of the current video frame can be retrieved from the callback function for the VideoTexture.RENDER_STATES event.

function renderFrame(e:Event):void

{

    // Render on stage3D with VideoTexture

}

Please note that this will be an "extended beta" feature.  The initial implementation, available  in our AIR 15 beta, will be for Windows/AIR only.  We are committed to expanding this feature to AIR mobile and Mac in a following release.  We'll also consider an implementation in Flash Player if there is sufficient demand.

Getting your feedback will be critical to making sure we're providing a solution that you can use.  Please let us know what you think and keep an eye out for updated beta release notes in the next couple of weeks.

TOPICS
Development

Views

20.6K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Using StageVideo and Stage3D in AIR - BETA

Adobe Employee ,
Aug 05, 2014

Copy link to clipboard

Copied

We're planning on introducing a new ActionScript feature that will allow hardware accelerated video to be used as a source texture in a Stage3D environment.  Currently, using video with Stage3D requires the use of the Video object, which is not accelerated, and manipulation of the bitmap representations of the video frames.  The planned feature, called VideoTexture, will allow direct access to a texture object that is sourced from a Netstream or Camera object.

The following sample code demonstrates the use of the VideoTexture object.

1) Create a VideoTexture object and attach a NetStream (or Camera) object to the VideoTexture object:

var ns:NetStream;

var context3D:Context3D;

var texture:VideoTexture;

texture = context3D.createVideoTexture();

texture.attachNetstream(ns);

ns.play("video.3gp");

texture.addEventListener(VideoTexture.RENDER_STATE, renderFrame);

2) A texture representation of the current video frame can be retrieved from the callback function for the VideoTexture.RENDER_STATES event.

function renderFrame(e:Event):void

{

    // Render on stage3D with VideoTexture

}

Please note that this will be an "extended beta" feature.  The initial implementation, available  in our AIR 15 beta, will be for Windows/AIR only.  We are committed to expanding this feature to AIR mobile and Mac in a following release.  We'll also consider an implementation in Flash Player if there is sufficient demand.

Getting your feedback will be critical to making sure we're providing a solution that you can use.  Please let us know what you think and keep an eye out for updated beta release notes in the next couple of weeks.

TOPICS
Development

Views

20.6K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 05, 2014 5
Adobe Community Professional ,
Aug 05, 2014

Copy link to clipboard

Copied

That might be nice, and I know at least one huge fan you're going to get! I'm going to post this link to a prerelease forum, expect to be inundated with praise.

Meanwhile, two things that would be useful, while you're working on these things, would be to have better support for StageVideo for playing local files (we had to give up in the end, and use FLVs and Video object), and, find a way for Stage3D to work in GPU mode, just like StageVideo and Stage Text does.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 05, 2014 0
Participant ,
Aug 05, 2014

Copy link to clipboard

Copied

It would be great if StageVideo could be progressed so the current bugs are eliminated. Especially for Air/Android. I have a working StageVideo AIR app on iOS which fails miserably on Android (black screen issues).

Perhaps this new Stage3D implementation might solve these issues???

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 05, 2014 0
New Here ,
Aug 06, 2014

Copy link to clipboard

Copied

Great news Chris!!! If you put this into mobile as well I will start my new game, because it needs this feature

Keep the good job guys! Flash rocks no matter what "they" say!!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 06, 2014 0
Participant ,
Aug 06, 2014

Copy link to clipboard

Copied

That's great news, and I like the syntax. Thanks Chris.

However, I'd like to also ask what's the status on overlaying a Stage3D context and StageVideo. That alone would work wonders, without the need for any kind of texture support. I know that used to be supported a while ago - contexts could be "transparent" - but apparently it was dropped a year or so ago (it was under test I suppose). I can't find the original links for that unfortunately.

To share my perspective, I've recently had a project where I had to overlay both under several different circumstances and my solutions were two fold (one for each case):

1. Dump every frame into a texture in real time. This was needed because I was masking a texture. This was less than ideal because copying a bitmap on every frame takes a lot of CPU resources, so the video quality suffered (I had to downscale it).

2. Have StageVideo occupy part of the screen, and Stage3D occupy another part of the screen; they never overlapped. This also worked, but it meant never overlaying elements... the elements that needed to cover both had to be made using the old Flash display list. So it's a little bit of a crazy solution with lower performance than ideal.

So both were less than ideal but would have worked better if I could overlay stage3d/stagevideo.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 06, 2014 1
Adobe Community Professional ,
Aug 06, 2014

Copy link to clipboard

Copied

I think that having hardware decoded video as a texture in Stage3D indirectly solves the problem of wanting transparent Stage3D over StageVideo. You only have to connect the net stream to your back most texture (or camera background if that exists in Stage3D), and you have what you wanted.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 06, 2014 0
Participant ,
Aug 06, 2014

Copy link to clipboard

Copied

Yes, but "indirectly" being the keyword. It's better but it still sounds like more hops than necessary to me.

I guess I just never quite understood why the context overlaying feature was added only to be removed later.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 06, 2014 0
Explorer ,
Aug 06, 2014

Copy link to clipboard

Copied

This is great news! Updating the texture on each frame works for me but this seems so much nicer! Can't wait for it on mobile!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 06, 2014 0