基於flash的web視頻對講直播測試

來源:互聯網
上載者:User

標籤:setting   main   details   rtc   frame   rac   bsp   clip   採樣   

由於項目的需求,要在web上實現視訊通話的需求。
現成的方案有WebRTC,基於瀏覽器的成熟方案,但是這個方案和公司項目需求有幾個點衝突。
後來考慮到基於flash的方案。
參考雷神的部落格 simplest_as3_rtmp_streamer
http://blog.csdn.net/leixiaohua1020/article/details/43936141

本機軟體環境Win7_64位下,IE11,Flash Builder 4.7, ffplay播放
網路攝影機採用羅技C930e,麥克風用網路攝影機內建的。
伺服器採用SRSv2.0_r2

編碼採用ActionScript3指令碼語言,flash.media.Video採集視頻,flash.media.Microphone採集音頻,
flash.net.NetConnection串連srs伺服器,flash.net.NetStream推流。

測試在區域網路內視訊通話。
視頻採集解析度為1280*720 30fps 200Kbps H264編碼。
音頻採用44100採樣率 單聲道 40kbps nellymoser編碼。
區域網路內測試延遲如下:

   

代碼改寫自雷神部落格,伺服器採用srs,特此感謝雷神,感謝Winlin。

 1 package { 2     import flash.display.MovieClip; 3     import flash.events.NetStatusEvent; 4     import flash.media.Camera; 5     import flash.media.H264Level; 6     import flash.media.H264Profile; 7     import flash.media.H264VideoStreamSettings; 8     import flash.media.Microphone; 9     import flash.media.SoundCodec;10     import flash.media.Video;11     import flash.net.NetConnection;12     import flash.net.NetStream;13     14     public class media extends MovieClip15     {16         private var nc:NetConnection;17         private var ns:NetStream;18         private var nsPlayer:NetStream;19         private var vid:Video;20         private var vidPlayer:Video;21         private var cam:Camera;22         private var mic:Microphone;23         24         private var screen_w:int=384;25         private var screen_h:int=216;26         27         public function media()28         {29             nc = new NetConnection();30             nc.client = {};31             nc.client.onBWDone = function():void {};32             nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);33             nc.connect("rtmp://192.168.100.168/testas3/");34             trace("NetConnection !!!");35         }36         37         private function onNetStatus(event:NetStatusEvent):void{38             trace(event.info.code);39             if(event.info.code == "NetConnection.Connect.Success"){40                 publishCamera();41                 displayPublishingVideo();42             }43         }44         45         private function publishCamera(): void{46             47             //Cam48             cam = Camera.getCamera();49             cam.setMode(1280, 720, 30);  50             cam.setKeyFrameInterval(30);51             cam.setQuality(200000, 90); 52             53             var x264profile:String = H264Profile.MAIN; // H264Profile.BASELINE;54             var x264level:String = H264Level.LEVEL_4_1;55             var h264setting:H264VideoStreamSettings = new H264VideoStreamSettings();  56             h264setting.setProfileLevel(x264profile, x264level); 57             58             //Mic59             mic = Microphone.getMicrophone();60             mic.codec = SoundCodec.NELLYMOSER;//SoundCodec.SPEEX61             mic.setLoopBack(false);62             mic.gain=55;63             mic.setUseEchoSuppression(true);64             mic.rate = 44;  65 66             ns = new NetStream(nc);67             ns.client = {};68             ns.addEventListener(NetStatusEvent.NET_STATUS, function(evt:NetStatusEvent):void {69                 trace ("NetStream: code=" + evt.info.code);70                 // TODO: FIXME: failed event.71             });72             73             //H.264 Setting74             ns.videoStreamSettings = h264setting; 75             ns.attachCamera(cam);76             ns.attachAudio(mic);77             ns.publish("1111", "live");78         }79         80         private function displayPublishingVideo():void {81             vid = new Video(screen_w, screen_h);82             vid.x = 20; 83             vid.y = 20;84             vid.attachCamera(cam);85             addChild(vid);86         }87     }88 }
View Code

 

基於flash的web視頻對講直播測試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.