Skip to main content
April 30, 2009
Question

DVR with fms3 , how to make it work?

  • April 30, 2009
  • 4 replies
  • 6345 views

Hi

I am trying to look for documentation on how the DVR functionality is working in fms3. It seems that I need to implement som server-side scripting to make DVR even work. In Flash Live Encoder there is an option to Record DVR, but it when I press the button, all I get is:

Thu Apr 30 2009 13:15:38 : Start DVR command received

Thu Apr 30 2009 13:15:38 : Requested DVR command has been successfully issued to Primary FMS server for stream ob1stream

Thu Apr 30 2009 13:15:38 : Primary - Network Status: NetConnection.Call.Failed error Method not found (DVRSetStreamInfo).

Does anyone know how to make this work?
Best Regards Niclas
    This topic has been closed for replies.

    4 replies

    ghost31379
    Inspiring
    May 4, 2009

    you know what....i failed to ask you what was your experience level with flash .....

    create a new actionscript file in in flash and paste that code there......and save the the file as   SimpleEncoder.as   ....(the name of the class).....then Create a new fla file...name it "test.fla" save the file in the same directory as the   SimpleEncoder.as   file created from the code i pasted....

    ok then inside of the    test.fla   file....at the bottom bar where it says "Document Class"....insert     SimpleEncoder    with the extension part ".as".....

    then ctrl+enter to preview.....or just goto the top menu and click preview.....then it should connect and show you..yourself ......i usually use my local computer first to test things out to see if it works to lessen the possibility of potential problems.....just incase.....

    Inspiring
    May 5, 2009

    Now _that's_ what I like to see: detailed info so one's sure not to miss anything.  Thanks for taking the time to be so specific, Ghost.  I'm pretty versed in Actionscript 2, but I'll admit, this transition to Actionscript 3 has been rough.  All this stuff about using external .as files and classes and importing classes, yikes, it feels very foreign to me.

    Getting back to your fine tutelage... alas, it's still not working for me.  : (

    One question... do I need to add a video component to the .fla file?  I'm thinking not since you don't appear to be a fan of components, but I don't know what else I could be missing.

    Could you attach a copy of your Flash Files so I can analyze them?  (And maybe a screen grab of your FMLE settings -- with names changed to protect the innocent if necessary?)  ; )

    Thanks for sticking with me, Ghost.

    ghost31379
    Inspiring
    May 4, 2009

    ok i'm back for a second......so uhhh....class is in session here is a basic example of a video encoder

    use this to stream your video while recording.....what makes it record?and not live? this line here:

      ns.publish("thefilename", "record");

    the second parameter.....to make it stream live without recording it to file you change it to "live"....the first parameter is what you name your file...

    after this you use your client player to connect to the same connection as outlined.....and to play the same file ..ie   stream.play("thefilename");

    package
    {
        import flash.display.*;
        import flash.media.*;
        import flash.net.*;
        import flash.events.*;
       
       
       
        public class SimpleEncoder extends Sprite
        {
            var nc:NetConnection;
            var ns:NetStream;
            var mic:Microphone;
            var video:Video = new Video();
            var camera:Camera;
           
            public function SimpleEncoder():void
            {
                NetConnection.defaultObjectEncoding = 0;
                nc = new NetConnection;
                nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                nc.connect("rtmp://localhost/video/myvids");
               
            }
           
            private function publishLiveStream():void
            {
                ns = new NetStream(nc);
                ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                ns.client = this;
                camera = Camera.getCamera();
                mic = Microphone.getMicrophone();
               
                if (camera != null){
                    camera.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
                    video = new Video();
                    video.attachCamera(camera);
                    ns.attachCamera(camera);
                }
                if (mic != null) {
                    mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
                    ns.attachAudio(mic);
                }
                if (camera != null || mic != null)
                {
                // start publishing
                // triggers NetStream.Publish.Start
                // "thefilename" is the name of the file you use after you connect to stream in client player   stream.play("thefilename");
                ns.publish("thefilename", "record");
                }
                else
                {
                    trace("Please check your camera and microphone");
                }
                addChild(video);
            }

           
            public function onBWDone():void
            {
               
            }
           
            private function netStatusHandler(event:NetStatusEvent):void
            {
                trace(event.info.code);
                switch (event.info.code)
                {
                    case "NetStream.Buffer.Full":
                        break;
                    case "NetStream.Buffer.Empty":
                        break;
                    case "NetConnection.Connect.Success":
                        trace("Congratulations! you're connected");
                        publishLiveStream();
                       
                        break;
                    case "NetConnection.Connect.Failed":
                    case "NetConnection.Connect.Rejected":
                       // trace ("Oops! the connection was rejected");
                        break;
                    case "NetStream.Play.Stop":
                        break;
                    case "NetStream.Play.StreamNotFound":
                        trace("The server could not find the stream you specified");
                        break;
                    case "NetStream.Publish.BadName":
                        break;
                    case "NetStream.Publish.Start":
                }
            }
           
            private function statusHandler(event:StatusEvent):void {
                trace("statusHandler: " + event);
                trace(mic.activityLevel);
            }
           
            private function activityHandler(event:ActivityEvent):void
            {
                //trace(mic.activityLevel);
            }
           
            public function onFault(e:Object)
            {
                //trace(e.info);
                //nc.close();
            }
           
           
           
        }//end class
    }//end package

    thelegendaryghost

    Inspiring
    May 4, 2009

    Wow, I appreciate the detailed info, Ghost.

    But somehow, it's still not working for me.  : /

    Could you attach a screen grab of your Flash Media Live Encoder settings (assuming you are using FMLE), as well as your source settings in the video player .fla file?

    I'll get to the bottom of this one way or another!  ; )

    Thanks again for your help.

    ghost31379
    Inspiring
    May 4, 2009

    Hrmmm.....the simplest way is to just have a button that seeks to different time periods while its recording live......and play from there....you dont need server side scripts or all that other mess....

    learn about it here....

    http://www.adobe.com/devnet/flashmediaserver/articles/live_dvr_pt1_05.html

    just go thru and read that

    then again...thats with FMS 3.5....lol read it anyway

    Inspiring
    May 4, 2009

    Turning my attention to your original post, Ghost...

    I walked through the tutorial you indicated on Understanding Live DVR, but, as usual, couldn't get it to work.  Even using the tutorials "Completed" versions that should theoretically be pristine, I'm getting a "NC STATUS: NetConnection.Connect.Failed" error.

    One thing that grabs my attention... there's no mention of a main.asc file anywhere, and since we created the directory from scratch, there therefore is no main.asc file in that directory, (which I assumed there always needs to be, no?)

    Do I need to copy and paste another main.asc from some other directory?

    ghost31379
    Inspiring
    May 4, 2009

    well ....let me start from the beginning......you dont need to touch main.asc or even have one at all.....as for as the recorder goes....you just need it recording to a file on server....not sure about pressing all those buttons in Flash Media Encoder just make sure the stream is being recorded to file and thats it for the recording side of the equation.....i couldnt find the simple file i created a while back to give you an example but either way.....

    the viewing side/client swf......you need it to connect to the same netstream string that you use in the recording swf or flash Media Encoder....if you using the flashMediaEncoder its the part that says "save to file" connect to that same folder and play that file in your player....and create the seek button and click......it will go back 10 secs......to return to current time....you would make another button that seeks to a ridiculously high number that doesnt exist so it goes to the most current time......

    the error you gave leads me to believe you're not connecting to the right folder.....like you connecting to a folder that doesnt exist.....

    if you want to....or if you connecting to a folder that you created in the application folder then it should be something like this

    application/video/streams/myvids

    thats the folder structure......but when you connect....you would connect

    rtmp://localhost/video/myvids

    then the play function would play

    stream.play("yourvideo");

    ps....you dont use the "streams" folder in your connection string when connecting but it must be there to work correctly

    Participating Frequently
    May 2, 2009

    Looking at your question, it seems there are two issues: -

    1. You are using FMS 3, and for DVR you need FMS 3.5

    2. You need to have DVRCast application on server side or your own custom application which have neccessary handlers namely DVRSetStreamInfo and DVRGetStreamInfo defined.  (DVRCast is still in pre-release and hopefully would be released soon, if you access to Adobe pre-release you can download DVRCast application from there)

    Now if you want to just see DVR functionality is working, you do following steps:

    1. Install FMS 3.5. (You can use Development Server if you just want give it a try or simply buy FMIS 3.5, its worth it )

    2. Create an application named "mydvr_app" with main.asc having following simple code:

    application.onConnect = function(myClient){

         return true;

    }

    application.onPublish = function(myClient,myStream){

         myStream.record( );

    }

    application.onUnpublish = function(myClient,myStream){

         myStream.record(false);

    }

    3. Download FLVPlayback 2.5 from http://www.adobe.com/products/flashmediaserver/tool_downloads/. Read the documentation in it how to use it. Create a simple client using FLVPlayback 2.5.

    4. Open any publisher client or simply use FMLE which you have, connect to "mydvr_app" on your FMS 3.5 and publish stream by name "mydvr_stream", if you are using FMLE 3.0 , just click on Start to publish (dont use DVR Record as it expects certain handlers to be defined on your server-side application as i mentioned earlier)

    5. Open client created using FLVPlayback 2.5, give source as "rtmp://<server-ip>/mydvr_app/mydvr_stream.flv". Compile the client and run it.

    Once you do all above steps, you will DVR in action

    I will try to write more in detail later with respect how you can define your own server-side application if you want to use "DVR Record" of FMLE 3.0

    Hope it answers your question. Please do post if something is remaining unanswered or if you wan to know more details.

    Inspiring
    May 4, 2009

    Hmmm, I tried your walk-through,  SE, but alas, no go.   I can see that a .flv file is being created in the default directory on the Flash Media Server, but no video can be seen in the FLVPlayback component 2.5 .

    The code snippet you provided for the main.asc file... is that all that needs to be in that file, or should it be pasted in among a bunch of other pre-existing main.asc code?

    ghost31379
    Inspiring
    May 4, 2009

    well....i'm sort of a control freak...lol so i dont use the flvplayback component...its a hassel after alot of custom coding....i prefer to make it work like i want from what i code so i just use the video object and create my own buttons......

    now doing it that way...being that i've done it before.....all i had to do was create a button that seeks to s previous time in the recording.....

    lets say you want to go back 10 seconds in time while viewing a live stream you would have a button that basically does this

      ns.seek( ns.time - history ); //history would be a variable that represents the 10 secs or whatever time

    that would be the simplest way....just have a file recording and in the client swf....create a seek button tha
    performs the above operation on click...like

    seek_button.addEventListener(MouseEvent.CLICK, doSeek);

    public function doSeek(event:MouseEvent):void
    {
        
    ns.seek( ns.time - 10 );

    }

    you dont have to touch the main.asc code or anything like that......