Skip to main content
August 19, 2011
Answered

Encoding on the server

  • August 19, 2011
  • 2 replies
  • 1139 views

How can I receive a 1.5Mbit stream from Flash Media Live Encoder and then re-encode it to 2 different streams?

It's much like what Ustream is doing. They receive one high-quality feed, and then re-encode to a couple of different qualities in realtime.

I want to do it this way because it's much more bandwidth-efficient.

Thanks.

    This topic has been closed for replies.
    Correct answer

    Well, you'd need some means of starting FFMPEG for each stream that is coming in to the server. I suppose you might be able to handle that with a C++ access plugin, but you wouldn't have any way to monitor the FFMPEG processes directly within server side actionscript. If you wanted to monitor those FFMPEG processes via server side actionscript, you'd need to build up an external process to handle it.

    As to calmchess' suggestion, yeah, I guess you could go about it that way, where you'd  respond to the onPublish event, call out to PHP (or another HTTP service), and have PHP execute FFMPEG. That still leaves you sort of stuck for monitoring the FFMPEG process... might be better to use a Java application so  you can keep a handle to the process open on a thread, and build up an HTTP responder for the java service to query for stats.

    There's another potiential issue when using FFMPEG. If I recall correctly, the rtmp library it uses isn't capable of publishing ouput to a named instance of an FMS application, so the output would have to go to the default instance of the target application (unless you want to build FFMPEG on your own and make changes to the rtmp library to handle instance names).

    2 replies

    August 19, 2011

    @JayCharles I don't want to use Wowza, as I understand there's some kind of patent infrigment lawsuit that Adobe has filled against them. Plus, it seems too complicated to use with my current software stack.

    I thought about using FFmpeg (As @calmchessplayer suggested) to handle the transcoding this way:

    Flash Media Live Encoder --(1 high-quality stream)--> Origin server (which is used as a transcoder too). The server runs FFmpeg to handle the streams transcoding -> Edge server -> Client.

    What do you think about this architecture? And does FFmpeg can even do a couple of transcodings at once and send them to the same server 'listener' (the live streaming application on FMIS)?

    Correct answer
    August 19, 2011

    Well, you'd need some means of starting FFMPEG for each stream that is coming in to the server. I suppose you might be able to handle that with a C++ access plugin, but you wouldn't have any way to monitor the FFMPEG processes directly within server side actionscript. If you wanted to monitor those FFMPEG processes via server side actionscript, you'd need to build up an external process to handle it.

    As to calmchess' suggestion, yeah, I guess you could go about it that way, where you'd  respond to the onPublish event, call out to PHP (or another HTTP service), and have PHP execute FFMPEG. That still leaves you sort of stuck for monitoring the FFMPEG process... might be better to use a Java application so  you can keep a handle to the process open on a thread, and build up an HTTP responder for the java service to query for stats.

    There's another potiential issue when using FFMPEG. If I recall correctly, the rtmp library it uses isn't capable of publishing ouput to a named instance of an FMS application, so the output would have to go to the default instance of the target application (unless you want to build FFMPEG on your own and make changes to the rtmp library to handle instance names).

    August 19, 2011

    What do you mean "C++ access plugin"? Any reference, please?

    I'll probably write a Python service to handle and monitor the FFmpeg transocding.

    And I think you're write regarding FFmpeg and the instance name. Last time I tried it -- it always sent the stream to a _definist_ instance. I'll have only one live stream initally, so it's not a big-deal right now.

    Something else I wanted to ask -- maybe do you know a way to monitor the number of streams across multiple servers in realtime? (I wanna know how many streams the system handles at any given moment.)

    August 19, 2011

    FMS doesn't support transcoding. If you want to use FMS, you'll need to publish two separate streams to the server.

    August 19, 2011

    Then how Ustream is doing it?

    I don't care if the transoding will be by third-party software. I just want it to work with FMS. Nobody has released a solution for this already?

    calmchessplayer
    Inspiring
    August 19, 2011

    try FFMPEG make sure you get the latest version and read up on its "transcodeing" capablities. I use a combination of PHP and batch files to automate it. But i usually just extract .jpg out of flv files and use them as thumbnails in a gallery. I use PHP becasue its web enabled and can execute a well executable myBat.bat