Publishing RTSP Streams on FMS! How?

For those who have ever used the Flash Media Server for video streaming, the idea of publishing a stream encapsulated in RTSP (Real Time Streaming Protocol) may seem quite strange, maybe even impossible. This is because the basic (and only) protocol used for FMS client-server communication is the RTMP (and its variations), a proprietary protocol for media streaming, from Adobe. However, in some circumstances the use of an RTMP input is almost impossible, especially when this input stream comes from legacy systems, or from external services. These specific cases require an approach where the content from a RTSP source is delivered using RTMP, that is, a translation from RTSP to RTMP via content repackaging.

The easiest way to perform this translation is using Wowza Media Server, an alternative to FMS that has many interesting features, including the RTSP input support. The problem is that sometimes is impossible to change the video architecture from FMS to other solution, especially when we have developed several applications, or when the whole environment is integrated, up, and running.

In this situation, the intuitive solution would be: we can setup a layer of Wowza Media Server before FMS Servers, working like a translation layer. With this layer, the FMS would receive a RTMP stream exactly like it receives from Flash Media Encoder, making the translation fully transparent. The challenge of this solution is that the Wowza Server cannot publish streams on FMS, so, it cannot act like a FME (from FMS perspective).

To deal with this limitation, we need to change the stream flow paradigm from push to pull, or, in other words, we need to force FMS to get the stream from Wowza. With this architecture configuration, the FMS is no longer a passive component. It is its responsibility to, not only get the video stream, but to perform the failover of the input streams, which can be done through stream multiplexing.

This change in FMS role is only possible if we use server side action script, to connect to Wowza, and to pull the stream flow. Basically, we use NetConnection and Stream classes, to establish a remote connection and to play some content (Wowza stream) through it:

myRemoteConn = new NetConnection();
myRemoteConn.connect("rtmp://wowzaserverhost/streamtest");
myStream = Stream.get("myStream");
myStream.play("my_stream.sdp", 0, -1, true, myRemoteConn);

As we can see, we can use the FMS to delivery RTSP streams without great architecture changes. With Wowza Media Servers and some server side AS, it’s not too hard to make the impossible, possible!

About these ads

13 comments so far

  1. paranoio on

    hey thanks for the info , i was wondering how to connect an ip camera to flash , thought it will be good to have a fully open source alternative to convert rtsp to rtmp and use it with red5.

    • Rafael Pereira on

      I’m not sure if you can do this procedure with Red5. I know that Red5 support RTSP inputs, but, I didn’t test the communication FMSRed5. But, since Red5 generates a RTMP stream as output, I believe that is possible. If you have only 1 camera, you can use Wowza also, because it is free for a max of 10 simultaneous users. However, if you are looking for a completely open source solution, so, Red5 is your only option.

  2. hakierkmiec on

    Is that true that it will working only if RTSP stream is encoded with h.264 codec?

    • Rafael Pereira on

      In theory, it should work if you use H.264, VP6 or Sorenson… because those are the video codecs supported by Flash Player… However, I was using Wirecast as RTSP stream source, and it only generates H.264 as output, so, I don’t know exactly if VP6 and Soreson will work.

  3. Alejandro on

    Hi, you know how make to from FMS send to other FMS a Live Stream?
    I use your example for poll from Wowza to FMS but currently need send to CDN the same stream.

    Thanks for any recommendation.
    Regards
    Alejandro

    • Rafael Pereira on

      Alejandro,

      sorry about the delay to answer you!… You can use server side action script to republish rtmp streams on different FMS:

      nc = new NetConnection();
      nc.connect(“rtmp://yourfmshost/yourfmsapp/”);
      ns = new NetStream(nc);
      ns.attach(myStream);
      ns.publish(myStream.name, “live”);

      Take a look at the FMS docs, and check the Server Side Action Script Reference, to get more detailed info about the NetStream methods.

      Regards

  4. StevieRayG on

    Did you test this or is it a simply theoretical? What versions of FMS and Wowza did you use for your test? The reason I ask is because I am attempting this same thing using Wowza 1.7.2 and FMS 3.5 and although I don’t get any errors, I don’t get any audio or video. It seems I only get the metadata for the stream.

    • Rafael Pereira on

      Stevie,

      yes, I really developed a solution to publish RTSP into FMS, using Wowza. In this occasion, I had to publish the RSTP output from Wirecast into FMS… I was using FMS 3.0 and Wowza 1.7.2, but I believe that it works with 3.5 also. The problem with this architecture is that it has a lot of layers, so, debbuging can become quite complex. In your case, check if the output from Wowza is working fine. You can use the wowza sample player (written in flash/action script) to do it. If everything is ok with wowza, FMS should pull the stream without problems. In my tests, I was using H.264 with MP3, so, the problem in your case can be with the A/V codecs… If you still having problems, send me an email with more details.

  5. videoicu on

    I need to pull 10-15 live streams from Wowza to FMS (at CDN). Does the CDN have to add an additional action script per your instuctions above for each new stream we add?

    • Rafael Pereira on

      For each stream you will need to tell FMS (via action script) what is the source content url on Wowza. However, you can write a generic SSAS to run on FMS, being URL independent. In this case, the same app will be used for all streams, so, you will need to add only 1 action script code on CDN.

  6. Max Lapshin on

    It is possible to use only http://erlyvideo.org/ : it can capture RTSP streams (with their archive recording) and show them to flash clients.

  7. crtmpserver on

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: