Wowza Community

BitmapData/draw() raises Security sandbox violation in Wowza 1.6, please help

Dear all,

I have Wowza 1.6 running on the same machine which hosts the swf client. I need to grab a frame from the flash video. The error I get is

SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: http://localhost/testApp.swf cannot access unknown URL. No policy files granted access.

Why am I getting this error when both Wowza and the client are on the same machine? I have fiddled with crossdomain.xml and that has not helped. Furthermore the code works fine on Flash Media Server 3 and older versions of Wowza. What do I need to change in Wowza? I have set “StreamVideoSampleAccess” to * in conf/Application.xml and still no success.

I guess if I can figure out why it says “No policy files granted access.” then I can crack it.

Thanks

This is what works for me. You will need to struggle with it. I have found it to be a pain in the you know what.

Do the following:

  • Install the examples/FastPlayVideoStreaming example

  • Edit [install-dir]/conf/fastplay/Application.xml and change the Client/Access section to look like this:

    <Client>
    	<IdleFrequency>-1</IdleFrequency>
    	<Access>
    		<StreamReadAccess>*</StreamReadAccess>
    		<StreamWriteAccess>*</StreamWriteAccess>
    		<StreamAudioSampleAccess>*</StreamAudioSampleAccess>
    		<StreamVideoSampleAccess>*</StreamVideoSampleAccess>
    		<SharedObjectReadAccess>*</SharedObjectReadAccess>
    		<SharedObjectWriteAccess>*</SharedObjectWriteAccess>
    	</Access>
    </Client>
    
    
  • In Flash CS3 create a new ActionScript 3.0 movie and add a video object to the library then to the stage. Name it videoObj. Add a button to the stage and name it snapshotBut.

  • Add this ActionScript code:

    import flash.display.*;
    import flash.utils.*;
    import flash.geom.*;
    import flash.media.*;
    var nc:NetConnection = new NetConnection();
    var ns:NetStream = null;
    var snapshotTimer:Number = 0;
    function ncOnStatus(infoObject:NetStatusEvent)
    {
    	trace("nc.onStatus: "+infoObject.info.code);
    	if (infoObject.info.code == "NetConnection.Connect.Success")
    	{
    		ns = new NetStream(nc);
    		var clientObj:Object = new Object();
    		clientObj.nsOnStatus = function(infoObject:NetStatusEvent)
    		{
    			trace("ns.onStatus: "+infoObject.info.code);
    		}	
      	
    		clientObj.onMetaData = function(infoObject:Object)
    		{
    			trace("ns.onMetaData");
    		}
      	
    		clientObj.onPlayStatus = function(infoObject:Object)
    		{
    			trace("ns.onPlayStatus: "+infoObject.code);
    		}
      	
    		ns.client = clientObj;
    		ns.addEventListener(NetStatusEvent.NET_STATUS, clientObj.nsOnStatus);
      	
    		videoObj.attachNetStream(ns);
      	
    		ns.play("Extremists");
    	}
    }
    function takeSnapshot(event:MouseEvent)
    {
    	clearInterval(snapshotTimer);
      
    	trace("takeSnapshot");
    	var b:BitmapData = new BitmapData(640, 360); 
        b.draw(videoObj); 
      
    	var mc:MovieClip = new MovieClip();
     	addChild(mc);
       	mc.graphics.beginBitmapFill(b, new Matrix(), true, true);
        mc.graphics.moveTo(0, 0);
        mc.graphics.lineTo(0, 360);
        mc.graphics.lineTo(640, 360);
        mc.graphics.lineTo(640, 0);
        mc.graphics.lineTo(0, 0);
        mc.graphics.endFill();
    }
    snapshotBut.addEventListener(MouseEvent.CLICK, takeSnapshot);
    nc.addEventListener(NetStatusEvent.NET_STATUS, ncOnStatus);
    nc.connect("rtmp://localhost/fastplay");
    
    

    This assume Wowza Pro is running on the same machine as Flash CS3.

    I really can’t support this. I am just leaving it as an example of what works for me. I have found this to be very hard to get working reliably. Even this example gives me scaling issues which I have spent hours trying to understand.

    Charlie

Thanks Charlie. It was actually one line of code in my app that was preventing the frame grab. Just before grabbing the frame the code was calling

videoObj.attachNetStream(null);

. Please note that I inherited the code from a developer who has left but I’m glad that I’ve finally tracked down the problem. Thanks again for taking your time to help.

Kind regards,

Ernie

Now,After 5 years.However, I encountered this problem either.

Thanks Charlie. According to his method, I solved the problem.

http://blog.vini123.com:slight_smile: