Webcam Stream to CDN FMS

风格不统一 提交于 2019-12-13 21:25:33

问题


I don't have my own Flash Media Server. I can however use the Highwinds CDN. They run FMS on their CDN. When you schedule a live event, Highwinds gives you two urls: the "server" and "stream name". Examples:

server: rtmp://fli003.am4.hwcdn.net/XXXX/definst

stream name: fli/00000-streamname?encoderuser=XXX&encoderpassword=YYY

These two urls can be pasted into the Flash Media Live Encoder application to stream the live event. The respective field names in Flash Media Live Encoder are "FMS URL" and "Stream".

I now have successfully established a connection (I think?) to the FMS server. The problem: the stream is not showing on the web, and it seems it is not submitted to the CDN.

function onStatus(e:NetStatusEvent):void {

trace(e.info.code);

    switch(e.info.code) {

      case "NetConnection.Connect.Success":
        var ns:NetStream = new NetStream(conn);

        ns.addEventListener(NetStatusEvent.NET_STATUS, onStatus);

        var camera = Camera.getCamera();
            camera.setLoopback(true);
            camera.setQuality( 0, 100 );
            camera.setMode(640, 480, 25)
        var mic = Microphone.getMicrophone();

        if (camera != null){
            myVid.attachCamera(camera);
            ns.attachCamera(camera);
//            ns.play();
        }
        if (mic != null) {
            ns.attachAudio(mic);
        }

        ns.publish("fli/00000-streamname?encoderuser=XXX&encoderpassword=YYY", "live");
        break;
        //...
    }
}

var conn:NetConnection = new NetConnection();



conn.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
conn.connect("rtmp://fli003.am4.hwcdn.net/XXXX/_definst_");


//var counter:int = 0;
//conn.onBWDone = function(kbitDown:Number, deltaDown:Number, deltaTime:Number, latency:Number){ };
NetConnection.prototype.onBWDone = function(p_bw) {
   //trace("onBWDone: "+p_bw);
}
NetConnection.prototype.onBWCheck = function() {
   //return ++counter;
}

The smil file is there, but I suspect that no data arrives at the server. The player is only showing a loading animation.

And I now get an additional

NetStream.Failed NetStream.InvalidArg NetStream.InvalidArg after successfully connecting. No idea where that error came from.


回答1:


check the NetStraem.publish() reference:

//...
conn = new NetConnection();
conn.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
conn.connect('rtmp://fli003.am4.hwcdn.net/XXXX/definst');
//...
private function onStatus(e:NetStatusEvent):void {
    switch(e.info.code) {
        case "NetConnection.Connect.Success":
        ns = new NetStream(conn);
        ns.attachCamera(camera);
        ns.publish("fli/00000-name?encoderuser=XXX&encoderpassword=YYY", "live");
        break;
        //...
    }
}


来源:https://stackoverflow.com/questions/4461054/webcam-stream-to-cdn-fms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!