Skip to main content
Participating Frequently
March 17, 2009
Question

FLV Stops Early

  • March 17, 2009
  • 2 replies
  • 2236 views
I am having problems trying to play an FLV with Flash Media Server 3. The FLV stops early with only a NetStream.Play.Stop. I do not believe this is a buffering issue where the end of the file is reached before the client plays the end of the file as I am playing the FLV as a lives tream on FMS and a client subscribes to the live stream. On the server the live stream is the one that sends a NetStream.Play.Stop message and the flex client no longer gets the FLV audio. Also the amount of time the FLV stops playing before the actual end of the file is random. Sometimes it only plays 1.5 minutes of a 30 min FLV, sometimes it plays 15 min, sometimes it plays all the way through. Starting the FLV at any point other than the beginning seems to make it slightly better, but it still has the same issue. Any ideas?
    This topic has been closed for replies.

    2 replies

    Participant
    March 18, 2009
    Right. testStream is a live stream. So if you connect to the app first time which server starts to load that instance, then you should be able to play stream all the way through. But if you connect to the app later after instance is already loaded, then you are joining in the middle of live. So you are missing the part. Same thing, if you play after vod is completely played back, then you won't see any as live is over.

    Other than this, if you are first client to connect and load the instance at the moment, and it just plays half way or sometimes just a little. Then, it's something wrong in the server.
    ptamilarAuthor
    Participating Frequently
    March 30, 2009
    quote:

    Originally posted by: -wj-
    ...
    Other than this, if you are first client to connect and load the instance at the moment, and it just plays half way or sometimes just a little. Then, it's something wrong in the server.




    Yes this is the case. I am the first client to connect, and FMS then plays a random amount from the FLV and stops early. I do believe it is something wrong with the server. I don't think it is the FLV itself as it plays fine from any FLV player, and the FLV was actually recorded from a clien't microphone on the same FMS server earlier using Stream.record(). Any ideas what it could be?
    Participant
    March 17, 2009
    If you are using server side stream object to play VOD file, stream becomes live to subscribers. When you subscribe, do you know how long it played in the server? I wonder this play stop event due to the live playback. Otherwise, could you post your server side script snippet? or steps to try out.

    Thanks.
    -wj
    ptamilarAuthor
    Participating Frequently
    March 17, 2009
    It says theres supposed to be a "Attach Code" button but I dont see one?


    The time it plays on the server is random, sometimes it only plays a few minutes of the stream, sometimes it plays almost all of it. The traces in the live log in FMS Console show that on our server the live stream stops early and never continues. Below is code for a complete test app that causes the issue for us.


    I created a small fms app, code is below.
    quote:


    // load the remoting classes
    load("netservices.asc");


    const FILENAME = "14216_0";
    const STREAMNAME = "testStream";

    application.onAppStart = function()
    {
    var s = Stream.get(STREAMNAME);
    s.onStatus = onStatus;
    s.onPlayStatus = onPlayStatus;
    trace("Length of stream is " + Stream.length(FILENAME));
    //s.setBufferTime(5);
    trace("Length of buffer is " + s.bufferTime);
    s.play(FILENAME, 0, -1, true);
    }

    application.onConnect = function(cl)
    {
    trace("onConnect called.");
    for (var prop in cl)
    {
    trace("\t" + prop + ":\t" + cl[prop]);
    }
    trace("");

    application.acceptConnection(cl);
    }


    application.onDisconnect = function(cl)
    {
    trace("onDisconnect called.");
    for (var prop in cl)
    {
    trace("\t" + prop + ":\t" + cl[prop]);
    }
    trace("");
    }

    application.onPublish = function(cl, s)
    {
    trace("onPublish called.");
    trace("\tClient info:");
    for (var prop in cl)
    {
    trace("\t\t" + prop + ":\t" + cl[prop]);
    }
    trace("");
    trace("\tStream info:");
    for (var prop in s)
    {
    trace("\t\t" + prop + ":\t" + s[prop]);
    }
    trace("");
    }

    application.onUnpublish = function(cl, s)
    {
    trace("onUnpublish called.");
    trace("\tClient info:");
    for (var prop in cl)
    {
    trace("\t\t" + prop + ":\t" + cl[prop]);
    }
    trace("");
    trace("\tStream info:");
    for (var prop in s)
    {
    trace("\t\t" + prop + ":\t" + s[prop]);
    }
    trace("");
    }


    function onStatus(info)
    {
    trace("[onStatus] " + info.code + " - " + info.description + " - " + info.level);
    }

    function onPlayStatus(info)
    {
    trace("Netstream.onPlayStatus called.");
    for (var prop in info)
    {
    trace("\t" + prop + ":\t" + info[prop]);
    }
    trace("");
    }





    I then created a small flex test client, that connects to rtmp://HOST/flvTest/test. Once it connects it calls playStream() which subscribes to the liveStream "testStream".
    quote:


    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*">
    <mx:Script>
    <![CDATA[
    import mx.core.UIComponent;
    private var nc:NetConnection;
    private var ns:NetStream;

    private const HOST:String = "xxx.xxx.xxx.xxx:1935";

    private function onCreationComplete():void
    {
    nc = new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS, onNCNetStatus);
    }

    private function onNCNetStatus(e:NetStatusEvent):void
    {
    addLog("[onNetConnectionStatus] " + e.info.code);

    if (e.info.code == "NetConnection.Connect.Success")
    playStream();
    }


    private function playStream():void
    {
    ns = new NetStream(nc);
    ns.client = this;
    ns.addEventListener(NetStatusEvent.NET_STATUS, onNSStatus);
    ns.bufferTime = .1;
    addLog("Stream's buffertime is " + ns.bufferTime);
    ns.play("testStream");
    }
    private function connect():void
    {
    nc.connect("rtmp://" +HOST + "/flvTest/test");
    }

    private function onNSStatus(e:NetStatusEvent):void
    {
    addLog("[NetStreamStatus] " + e.info.code);
    }

    private function disconnect():void
    {
    nc.close();
    }

    public function onMetaData(info:Object):void
    {
    for (var propName:String in info)
    {
    var val:String = info[propName];
    addLog("[onMetaData] " + propName + " = " + val);
    }
    }

    public function onPlayStatus(info:Object):void
    {
    for (var propName:String in info)
    {
    var val:String = info[propName];
    addLog("[onPlayStatus] " + propName + " = " + val);
    }
    }

    private function addLog(text:String):void
    {
    var d:Date = new Date();

    txtLog.text += d.toLocaleDateString() + " " + d.toLocaleTimeString() + text + "\n";
    }
    ]]>
    </mx:Script>
    <mx:Panel width="80%" height="80%" layout="vertical" verticalCenter="0" horizontalCenter="0" title="FLVTest" creationComplete="onCreationComplete()">
    <mx:TextArea width="100%" height="100%" id="txtLog"/>
    <mx:ControlBar horizontalAlign="center">
    <mx:Button label="Connect" buttonMode="true" click="connect()"/>
    <mx:Button label="Disconnect" buttonMode="true" click="disconnect()"/>
    </mx:ControlBar>
    </mx:Panel>

    </mx:Application>




    I placed a sample FLV into /usr/local/macromedia/fms/applications/flvTest/streams/test/14216_0.flv.