Skip to main content
Known Participant
August 20, 2010
Answered

Recording in f4v format at FMS and then republishing to another server?

  • August 20, 2010
  • 4 replies
  • 3756 views

My data path looks like this:

Live Stream Encoder====>My FMS (my own server) republish to======>CDN======>Viewing Client

I want to archive the live stream at the first stop, my FMS.  Adobe live docs say if I want the recorded file to be of format F4V (H.264), the stream name with which I publish must be of the format mp4:streamname.f4v.  My CDN, unfortunately, requires the stream name it receives to be of the format "streamname".

How do I satisfy both?

In my onPublish() function I do two things:

1.  Record the live stream to a file

2.  Republish the stream to the CDN

Here is that method as it's currently constructed:

application.onPublish = function(client, stream) {
    trace("onPublish");

    //First record the stream here at this server 
    s = Stream.get("mp4:streamname.f4v");
    if(s){
        s.record();
        s.play(stream);
    }

    //Then pass the stream on to the CDN
    this.doRepublish(this.nc, stream);
};

Is there anyway to satisfy both requirements?

    This topic has been closed for replies.
    Correct answer Asa_-_FMS

    Hi Rex,

    Your assesment is correct and your CDN's requirement isn't going to make it possible to record H264 files from a live stream.  They may already be aware of this choice they've made, or if not you can point them back to Adobe/FMS where we can point out that this isn't possible given this req.  I'd recommend pointing this out so that they may remedy it for you.  If they can't or won't I imagine you'll want to find a CDN who will support this case for you.

    Asa

    4 replies

    August 26, 2010

    OK I figured it out. It was my own bonehead reading of the reference...

    My code should read:

        Client.prototype.recordLive = function()
            {
                this.liveStream = Stream.get("MP4:mynews.f4v");
                if (this.liveStream){
                    this.liveStream.record();
                    this.liveStream.play("news", -1, -1);               
                }
                trace("Recording in progress.");
            };

    I had the server stream I was creating the same name as the one from the client. That was the problem I think. Once I changed:

    this.liveStream = Stream.get("MP4:news.f4v");

    to

    this.liveStream = Stream.get("MP4:mynews.f4v");

    Everything worked right. I still can't get it to stream, but at least I can convert on the server to FLV with FFMPEG and move it to the right directory to serve correctly.

    Thanks for whoever might have been working on a solution.

    Known Participant
    August 27, 2010

    I just had that f4v archive file streaming black thing.  For me it came about when I archived in f4v format at the server as you have outlined in your code, but I failed to set my encoder to encode in H.264 format.  It was set to VP6.

    August 26, 2010

    OK. I have ammended my code and now get a file with an f4v extension and that has data in it of some sort, but it plays back as black in an FLV viewer on the server and doesn't stream at all. Any ideas?

    Code follows.

        Client.prototype.recordLive = function()
            {
                this.liveStream = Stream.get("MP4:news.f4v");
                if (this.liveStream){
                    this.liveStream.record();
                    this.liveStream.play("news", -1, -1);               
                }
                trace("Recording in progress.");
            };
           
        Client.prototype.stopRecord = function()
            {
                this.liveStream.record(false);
                this.liveStream.flush();
                trace("Recording has stopped.");
            };

    August 26, 2010

    I am trying simply to record an f4v file on the server and am having trouble. The file appears to start writing then when I am done, it is always 21k and never contains anything. My code follows:

        Client.prototype.recordLive = function()
            {
                this.liveStream = Stream.get("MP4:news.f4v");
                if (this.liveStream){
                    this.liveStream.record();
                    this.liveStream.play(stream);               
                }
                trace("Recording in progress.");
            };
           
        Client.prototype.stopRecord = function()
            {
                this.liveStream.record(false);
                this.liveStream.flush();
                trace("Recording has stopped.");
            };

    Can someone point me in the right direction here.

    Also I am not the brightest bulb in the box so when you write this.liveStream.filename or whatever, I never know if that is literally "filename" or the actual file name so feel free to use "news" as the stream and add whatever endings and so on that you need. Sorry...

    Adobe Employee
    August 22, 2010

    I think in order to record in f4v format at your local FMS you need to change one line of your code i.e.

    change s.play(stream); ==> s.play(stream.name,-1,-1)

    I think above change will record file in f4v format.

    I don't know what you have coded inside your doRepublish method, but again if you are publishing it to CDN server and want it recorded there in f4v format, you either have to recording code similar as what you have at recording local fms OR publish using as doc says i.e. use streamname as "mp4:streamname.f4v" in doRepublish method

    Known Participant
    August 23, 2010

    Thanks.

    That seems to produce the same result - a file in .flv format.

    I think the problem is the stream name and not the code.  Both lines of code ("s.play(stream);" and " s.play(stream.name,-1,-1)") record the incoming stream.  The recorded file format, however, appears inextricably linked to whatever name you used to encode the stream - i.e. whether or not "mp4:" and ".f4v" are there.

    If I leave my CDN out of it, and I just stream from my encoder to my server and record, it works.  I use the stream name "mp4:streamname.fv4" in my encoder and either of the two Stream.play() lines above.  The resultant archive file .f4v format.

    When I add the CDN to the picture the stream name "mp4:streamname.f4v" is not supported by them.  They say the stream name must be of format "streamname".  If I'm not mistaken, it seems there is no way to satisfy both - to say encode with the "mp4:" and ".f4v" but then do a name change at my server before sending the stream along to the CDN.  It seems Stream.name is a read only property.  Can you see anything I'm missing here?

    Asa_-_FMS
    Adobe Employee
    Asa_-_FMSCorrect answer
    Adobe Employee
    August 23, 2010

    Hi Rex,

    Your assesment is correct and your CDN's requirement isn't going to make it possible to record H264 files from a live stream.  They may already be aware of this choice they've made, or if not you can point them back to Adobe/FMS where we can point out that this isn't possible given this req.  I'd recommend pointing this out so that they may remedy it for you.  If they can't or won't I imagine you'll want to find a CDN who will support this case for you.

    Asa