问题描述
- flex rtmp wowza不能发布视频
- 请教个问题。我用flex + rtmp + wowza想实现视频的推送和接收。我使用如下的代码推送视频,但是在wowza服务器上却直接停止了我的推送操作,请问这是什么原因呢?
<?xml version=""1.0"" encoding=""utf-8""?><s:Application xmlns:fx=""http://ns.adobe.com/mxml/2009"" xmlns:s=""library://ns.adobe.com/flex/spark"" xmlns:mx=""library://ns.adobe.com/flex/mx"" minWidth=""955"" minHeight=""600""> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <fx:Script> <![CDATA[ private var connection:NetConnection; private var stream:NetStream; private var m_camera:Camera; public function VideoExample():void { connection = new NetConnection(); connection.addEventListener(NetStatusEvent.NET_STATUS netStatusHandler); connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR securityErrorHandler); connection.connect(txtURL.text); } private function netStatusHandler(event:NetStatusEvent):void { switch (event.info.code) { case ""NetConnection.Connect.Success"": trace(""成功连接FMS服务器!""); publishStreamVideo(); // 接收视频 break; case ""NetConnection.Connect.Rejected"": trace (""访问FMS服务器权限不足连接被拒绝!""); break; case ""NetConnection.Connect.InvalidApp"": trace(""指定的应用程序名称没有找到""); break; case ""NetConnection.Connect.Failed"": trace(""连接失败!""); break; case ""NetConnection.Connect.AppShutDown"": trace(""服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭!""); break; case ""NetConnection.Connect.Closed"": trace(""与FMS的连接中断!""); break; } } // 发布视频 private function publishStreamVideo():void { var stream:NetStream = new NetStream(connection); var microPhone:Microphone = Microphone.getMicrophone(); stream.attachAudio(microPhone); stream.attachCamera(m_camera); stream.client = this; stream.publish(txtID.text); } private function securityErrorHandler(event:SecurityErrorEvent):void { trace(""securityErrorHandler: "" + event); } private function asyncErrorHandler(event:AsyncErrorEvent):void { trace(""securityErrorHandler: "" + event); } // 推送视频 protected function button1_clickHandler(event:MouseEvent):void { VideoExample(); } // 连接摄像头 protected function btnOpenCamera_clickHandler(event:MouseEvent):void { m_camera = Camera.getCamera(); var m_video:Video = new Video(m_camera.width * 2 m_camera.height * 2); m_video.attachCamera(m_camera); sprct.addChild(m_video); } ]]> </fx:Script> <s:TextInput id=""txtURL"" x=""78"" y=""49"" width=""244"" text=""rtmp://localhost/videochat""/> <s:TextInput id=""txtID"" x=""78"" y=""79"" width=""244"" text=""testing""/> <s:Button x=""351"" y=""76"" label=""推送视频"" click=""button1_clickHandler(event)"" /> <s:VideoDisplay id=""sprct"" x=""79"" y=""101"" width=""351"" height=""238""/> <s:Button id=""btnOpenCamera"" x=""351"" y=""48"" label=""打开摄像头"" click=""btnOpenCamera_clickHandler(event)""/></s:Application>
时间: 2024-11-03 20:48:25