Skip to main content
miquael
Inspiring
July 2, 2009
Question

RTMP basics

  • July 2, 2009
  • 2 replies
  • 7998 views

Hello, I'm a seasoned ActionScript programmer, yet fairly new to Flash video, FMS, and RTMP.

I've been developing a custom Flash video player, and we now need it to use RTMP with FMS.  Despite my attempts, it is not working. 

Is it required that I use the FLVPlayback component to use RTMP?

I'm using SWFObject to pass parameters into the video player, including the URL to the video.  It works just fine with HTTP requests, but does not work with RTMP:

flashvars.videoPath_100 = "rtmp://e1f1.simplecdn.net/play/_definst_/video/test1.flv";

Is this a correct use of RTMP?  I read something somewhere that vaguely stated you do not use ".flv" at the end of the RTMP call.  Is that correct?

Also, what if I am using mp4 files, is it then like this:

flashvars.videoPath_100 = "rtmp://e1f1.simplecdn.net/play/_definst_/video/test2.mp4";

We are on a tight deadline, and need to get this working asap.  Any insights offered will be greatly appreciated.

Thanks

    This topic has been closed for replies.

    2 replies

    Participating Frequently
    July 2, 2009

    You first need to connect to FMS application and then issue play. I am assuming you are doing that.

    Say you an have an application named "test" on your FMS and media file named "sample.flv" in streams/_definst_ of "test" application.So in this case you have

    flashvars.videoPath_100 = "rtmp://e1f1.simplecdn.net/test/_definst_/sample.flv";.

    Now you have to extract ""rtmp://e1f1.simplecdn.net/test" as connection URL and "sample" as stream name for issuing NetStream.play.Also issue NetStream.play with correct parameters(0 for recorded files and -1 for live - as second paramatere) . You are right about thing you say about playign FLV files, you have to skip specifying extension , you just give file name without extension. When you playing mp4, you need to give stream name as "mp4:sample.mp4" if file extension is mp4 or "mp4:sample.f4v" is file extension is f4v (in case if file does not have any extension you just specify "mp4:sample" as stream name.

    So in above case if you had "sample.f4v" in streams/_definst_ of "test" application

    flashvars.videoPath_100 = "rtmp://e1f1.simplecdn.net/test/_definst_/mp4:sample.f4v";.

    Now if your were conecting to different instance say "room" and your file was present under "streams/room/video" then

    flashvars.videoPath_100 = "rtmp://e1f1.simplecdn.net/test/room/video/mp4:sample.f4v";. where you should use ""rtmp://e1f1.simplecdn.net/test/room" as your connection url and "video/mp4:sample.f4v" as your stream name.

    Hope this answers your question.

    miquael
    miquaelAuthor
    Inspiring
    July 2, 2009

    So I need to have the custom video player make a special request to FMS before making this RTMP call?  That might be the issue! I don't know much about FMS.

    The code is simply setting up a NetConnection and a NetStream:

    var nc:NetConnection = new NetConnection();

    nc.connect(null);

    var ns:NetStream = new NetStream(nc);

    ns.bufferTime = videoBufferTime;

    ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);

    var meta:Object = new Object();

    ns.client = meta;

    video.attachNetStream(ns);

    And then when the user clicks "PLAY":

    ns.play(currentVideoURL);

    Which is the URL we are passing thru SWFObject.

    So is there something else that needs to be established with FMS?

    miquael
    miquaelAuthor
    Inspiring
    July 2, 2009

    Okay ... after reading the rest of your message, I will go research "NetStream.play" ...

    Inspiring
    July 2, 2009

    You just need to put the instance name so if you have an instance called 'test' it would be rtmp://e1f1.simplecdn.net/test/test1.flv

    there is no need to put the sub directories of the instance.

    so in your case it should just be:

    rtmp://e1f1.simplecdn.net/play/test1.flv

    Paul

    miquael
    miquaelAuthor
    Inspiring
    July 2, 2009

    I tried this:

    rtmp://e1f1.simplecdn.net/play/test1.flv

    But the video still does not load (cannot be found).

    I am using http://www.simplecdn.com StormFront service.  According to the account specification, the RTMP URL should look something like this:

    rtmp://e1f1.simplecdn.net/play/_definst_/video/<<path_to_your_file>>

    Which in my case, would be:

    rtmp://e1f1.simplecdn.net/play/_definst_/video/test1.flv

    The "video" is the name of the bucket that I set up for the account to hold the video files.

    I am interested in what you are saying.  Do you have any more insight into this?

    Participating Frequently
    July 2, 2009

    Just try removing .flv and see if it works.