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的

就在今天中午,無意間再次谷歌了下錯誤,找到一個人跟我的一模一樣的實現方式,和同樣的錯誤

https://groups.google.com/forum/#!msg/c-rtmp-server/aACuxdF0Azw/mzkphlQHYeoJ

我把解決辦法摘抄上來

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" 
        }, 
        { 
          ip="0.0.0.0", 
          port=6666, 
          protocol="inboundLiveFlv", 
          waitForMetadata=true, 
        }, 
        { 
          ip="0.0.0.0", 
          port=9999, 
          protocol="inboundTcpTs" 
        }, 
        --[[{ 
          ip="0.0.0.0", 
          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++)

剩下最後一個 視頻錄像的功能了,唉不知道怎麼實現


發佈了74 篇原創文章 · 獲贊 28 · 訪問量 22萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章