天天看点

FLEX 截图crtmpserver服务器的rtmp流视频报 SecurityError: Error #2123

去年11月份开始来到这家新公司,做视频监控的

而我负责做web观看端,之前是说视频播放用flash来做,然后界面的话直接用原生的html

后来就温习了css js jq ajax...... 还有dwr

也做了一个类似的小demo出来,当然没什么功能,只能播放rtmp视频流而已

后来今年回来说都用flex做,到现在3 、4个月了,功能差不多实现了

还差一个视频截图加一个视频录像的功能,昨天开始做截图,网上找方法,还挺简单的

但是应用到视频截图就报错了:

securityerror: error #2123: 安全沙箱冲突:bitmapdata.draw:

xxx 不能访问 rtmp://xxxxx。未被授权访问任何策略文件。

网上也很多人遇到这个问题,说的方法但是都没有解决我的问题

由于我们的视频服务器是用crtmpserver,网上的解决办法大多是fms的

就在今天中午,无意间再次谷歌了下错误,找到一个人跟我的一模一样的实现方式,和同样的错误

我把解决办法摘抄上来

that worked beautifully, though i had to do a little more work then 

that. 

in void baseoutnetrtmpstream::signalattachedtoinstream(), i added the 

following code after stream begin to allow video samples: 

+        //xxx. notify |rtmpsampleaccess 

+    /* 

+        message = streammessagefactory::getnotifyrtmpsampleaccess( 

+                        _pchannelvideo->id, _rtmpstreamid, absolutetimestamp, false, true, 

true); 

+        track_message("message:\n%s", str(message.tostring())); 

+        if (!_prtmpprotocol->sendmessage(message)) { 

+                fatal("unable to send message"); 

+                _prtmpprotocol->enqueuefordelete(); 

+                return false; 

+        } 

+  */ 

also in the same method, changed the same call for the audio channel: 

    //10. notify |rtmpsampleaccess 

    message = streammessagefactory::getnotifyrtmpsampleaccess( 

        _pchannelaudio->id, _rtmpstreamid, 0, true, true, true); 

    track_message("message:\n%s", str(message.tostring())); 

    if (!_prtmpprotocol->sendmessage(message)) { 

      fatal("unable to send message"); 

      _prtmpprotocol->enqueuefordelete(); 

      return; 

    } 

this works perfectly to get flash bitmapdata.draw() to work on the 

rtmp stream. i suggest this be integrated as a configuration option to 

each application so it would be possible to do something like from the 

app configuration: 

      description="flv playback sample", 

      name="flvplayback", 

      protocol="dynamiclinklibrary", 

      aliases= 

      { 

        "simplelive", 

        "vod", 

        "live", 

        "weeklyquest", 

        "sosample", 

        "oflademo", 

      }, 

    acceptors = 

        { 

          ip="0.0.0.0", 

          port=1935, 

          protocol="inboundrtmfp" 

        }, 

          port=6666, 

          protocol="inboundliveflv", 

          waitformetadata=true, 

          port=9999, 

          protocol="inboundtcpts" 

        --[[{ 

          port=554, 

          protocol="inboundrtsp" 

        },]]-- 

      externalstreams = 

      validatehandshake=true, 

      keyframeseek=true, 

      seekgranularity=1.5, --in seconds, between 0.1 and 600 

      clientsidebuffer=12, --in seconds, between 5 and 30 

      allowvideosampleaccess=true, 

      allowaudiosampleaccess=true, 

    }, 

a big thanks for pointing me in the right direction! 

上面是那位外国仁兄解决办法:特此记录下(就是把上面加粗的代码放到你的视频服务器代码中,具体我不清楚,我不会c++)

剩下最后一个 视频录像的功能了,唉不知道怎么实现