Skip to main content
Participant
June 3, 2010
Question

How do you watch and record a live h.264 stream at the same time using fmis and FMLE?

  • June 3, 2010
  • 1 reply
  • 1002 views

I've read all the similar post but could not find a solution that actually works, and please no "just use the dvr or record on the FMLE suggestions" as neither will work for me.

Some posts I've read suggest naming the stream in the FMLE to something like mp4:mystream.mp4 or mp4:mystream.f4v but then you can no longer view the stream, and according my the admin console the stream will not even publish using this syntax.

I can view the published stream if I name the FMLE stream to something like mystream.mp4 or just mystream, but then it doesn't record at all or records as a FLV file depending on how I code the main.asc file.

Here's one version of my main.asc, this one correctly publishes the live stream after the client triggers the joinStreams function but will not record it.

application.onConnect = function (client, userType)
{

    trace("userType is " + userType);
    this.acceptConnection(client);
    //this.clientCount++;

    client.joinStreams = function (channel)
    {
        trace("joinStreams on channel " + channel);

        liveVid = Stream.get("livevideo/" + channel + ".mp4");
        liveVid.play("hdvideo/" + channel, -1, -1);
        liveVid.record("append");
    }

    client.clearStream = function (channel)
    {
        trace("clearStream on channel " + channel);
        liveVid = Stream.get("livevideo/" + channel + ".mp4");
        liveVid.play(false);
        delete liveVid;

    }

I've been working on this for 48 hours straight, please advise.

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    June 3, 2010

    I think lets keep it simple, will explain what you have for watching live streams and recorded streams

    Live Publish and Play:

         FMLE Settings:

      • Video Codec: H.264
      • Audio Codec:<any of your choice>
      • Server URI : Please put your server uri with application name here , for example i will use "rtmp://myServer/myApp"
      • Stream name: livestream

        Subscriber Settings:

      •           Server URI :  "rtmp://myServer/myApp"

                  Stream name: livestream

                  Mode: "live" ( i.e. ns.play("livestream",-1,-1,true)

    Playing VOD H.264 file:

         Subscriber settings:

      •           Server URI :  "rtmp://myServer/myApp"
      •           Stream name: if file name is "sample", use "mp4:sample", if file name is sample.f4v, use "mp4:sample.f4v"
      •           Mode: "record" ( i.e. ns.play("mp4:sample.f4v",0,-1,true)

    For DVR (Record-in-progress stream)

    If you are using FMLE and want to use "Record" option of FMLE then you need to have to dvrcast_origin application and subscrier needs to FLVPlayback 2.5 component

    If you want to use that option, do let me know i will give details later.

    For now we will use simple server-side code and FMLE as publisher.

    main.asc of "myApp"

    application.onPublish = function(myclient,mystream){

         mystream.record();

    }

    application.onUnpublish = function(myclient,mystream){

         mystream.record(false);

    }

    FMLE Settings:

      • Video Codec: H.264
      • Audio Codec:<any of your choice>
      • Server URI : Please put your server uri with application name here , for example i will use "rtmp://myServer/myApp"
      • Stream name: mp4:mydvrstream.f4v

        Subscriber Settings:

      •           Server URI :  "rtmp://myServer/myApp"

                  Stream name:  mp4:mydvrstream.f4v

                  Mode: "live" ( i.e. ns.play(" mp4:mydvrstream.f4v",0,-1,true)

    Try out above and let me know if that works or does not work for you.

    fmsadminAuthor
    Participant
    June 3, 2010

    Thanks for the reply. I've already gotten it to stream live h.264 and I've gotten it to record, just never both at the same time.

    Here what I did

    I cut and pasted your sass right into my main.asc and restarted fmis.

    changed the subscriber format to ns.play(" mp4:mydvrstream.f4v",0,-1,true) as instructed

    and in the encoder I changed the stream name to "mp4:mydvrstream.f4v"

    Result, subscriber could not play back the stream and no file recorded.

    Then I took another look the the ns.play line in the subscriber, and I changed it to ns.play(" mp4:mydvrstream.f4v",-1,-1,true) as I think the "0" is only for playing recorded files - but the results where the same.

    No errors. nothing interesting in the logs. Any other ideas?

    fmsadminAuthor
    Participant
    June 3, 2010

    Correction, the stream did record. It was just in the parent directory of the one I was expecting it to be in.

    Still can't get the subscriber to view the live stream if the stream has the mp4 prefix.