Pages

Drawing streamed video with Papervision 2.0 (Flash Media Interactive Server 3)


The new Flash Player 9 places a lot on emphasis on the security of streamed content audio and video. A previous Papervision hack allowed access to rtpm content by disconnecting "from the stream, doing a .draw() to a bitmapdata, and reconnecting. This procedure enabled streaming video to be played on a 3D plane". This is no longer possible.
However all is not lost. Flash Media Interactive Server 3 has a property of the Client class, "videoSampleAccess". This property allows the Flash Player read the raw uncompressed video data streamed from the server. Using this property you can set permissions for access to video data in designated folders. To use streamed video from FMIS set up the following statement in your server script.

application.onConnect = function(newClient)
{
this.acceptConnection(newClient);

//newClient.videoSampleAccess = 'pv3dstrms';
newClient.videoSampleAccess = '/';

The newClient.videoSampleAccess property allows the client application access to raw data of the video streamed from a target folder ( 'pv3dstrms' ) or any/all stream folders/ subfolders ('/') . On the client side set up your usual scaffolding to connect to Flash Media Interactive Server, set up your Video object, and your Netstream. Pass them as arguments to the VideoStreamMaterial. Assign the material to the primitive.

_vns = new NetStream(_vnc);

_vns.play("sample_c");

_cvidmat= new VideoStreamMaterial( new Video(), _vns);

_cube = new Cube( new MaterialsList({all:_cvidmat}), 300, 300, 300, 1, 1, 1, 0, 0):

*IMPORTANT: In your Event.ENTER_FRAME listener method put in the .updateBitmap(). Using the VideoStreamMaterial declared above it will be, _cvidmat.updateBitmap()

** Open the file VideoStreamMaterial.as in the PV3D materials classes folder and comment out the following statement :

"//this.video.attachNetStream ( null );"

Run your application.
Voila, you will be streaming video from FMIS.

*~* This method of FMIS/Papervision Video Streaming was tested with Great White and Effects branches of Papervision 2.0

*** I have not tried this on any other RTMP Socket server, so I cannot guarantee success with Red5, haXeVideo or Wowza but, it works for FMIS 3. I unfortunately cannot give a live preview as I go not have a public FMIS 3 install.

aYo Binitie II

10 comments:

DecoX said...

Excellent, I had a similar bug and I did the same!

Seantron said...

Nice work on this, but have you tried it lately? I've followed your instructions to the T, and I'm still throwing bitmap.draw errors on compile. The only work around I've found now is to wrap a CS3 FLV Playback component in a MovieMaterial, and pass in the RTMP via the source. Have you had any issues lately with this?

Sean

aYo ii said...

As a matter of fact I have, I got an email from someone who had an identical problem to yours. The problem was the point at which his loop was starting in relation to the start of NetStream play. The moment I adjusted the logic so the EnterFrame event started after the start of the stream all was well.

Seantron said...

That's exactly how I had to fix it too. It was being called too early.

This is what I did with it:

http://labs.influxis.com/?p=73

What a pain it was to figure it out.

But your post really helped get me going, thanks again.

Guy said...

Hi,
This is a great post, but when tried to implement I still get the bitmapdraw.error.
Also tried the timing issue (Enterframe after stream start).
can you please post here or send a working example (PV cube + main.asc)?

Thank you very much in advance,
Guy
guymeiri at gmail com

aYo ii said...

I'll post the code, tonight

turbidity said...

Ah! Thanks so much. I couldn't find what the string was to enable access to all subfolders. I kept assuming it had to be "*" rather than "/". Thanks for the assist!

Space Cowboy said...

Does this work with videos hosted on another server? Or do I run into the same cross-domain security problems?

Like, if I am using a streaming video off of a CDN, does this work for that?

aYo ii said...

With video streamed from a CDN it may not be possible except you have a deal with them to allow you access to the streams rawdata. On a personal server you can set the permissions

andy said...

Web casting, or broadcasting over the internet, is a media file (audio-video mostly) distributed over the internet using streaming media technology. Streaming implies media played as a continuous stream and received real time by the browser (end user). Streaming technology enables a single content source to be distributed to many simultaneous viewers. Streaming video bandwidth is typically calculated in gigabytes of data transferred. It is important to estimate how many viewers you can reach, for example in a live webcast, given your bandwidth constraints or conversely, if you are expecting a certain audience size, what bandwidth resources you need to deploy.

To estimate how many viewers you can reach during a webcast, consider some parlance:
One viewer: 1 click of a video player button at one location logged on
One viewer hour: 1 viewer connected for 1 hour
100 viewer hours: 100 viewers connected for 1 hour…

Typically webcasts will be offered at different bit rates or quality levels corresponding to different user’s internet connection speeds. Bit rate implies the rate at which bits (basic data units) are transferred. It denotes how much data is transmitted in a given amount of time. (bps / Kbps / Mbps…). Quality improves as more bits are used for each second of the playback. Video of 3000 Kbps will look better than one of say 1000Kbps. This is just like quality of a image is represented in resolution, for video (or audio) it is measured by the bit rate.

Instagram