[Red5devs] Taking a snapshot from a live video feed

Walter Tak walter at waltertak.com
Wed Sep 3 09:52:26 PDT 2008


Yep, 

you stil need to execute ffmpeg to convert it from FLV to JPG.

You can either schedule this on the (other) webserver using a cronjob which then loops through a directory and starts converting all FLV's it can find into JPGs or you can execute ffmpeg on the fly, as soon as Red5 calls the PHP-script and the script has succesfully downloaded the FLV.

See the example I quoted below for the exact parameters for FFMPEG. I guess you don't have a problem replacing the dynamic filenames etc with your own.

FFMPEG is basically the only command-line tool available for Unix and Windows that can convert sorenson spark FLV into JPGs. 
All (well most) other tools on the market have guis and can't be automated or called from scripts.

Regards,
Walter

  ----- Original Message ----- 
  From: Valentin Manthei 
  To: red5devs at osflash.org 
  Sent: Wednesday, September 03, 2008 4:10 PM
  Subject: Re: [Red5devs] Taking a snapshot from a live video feed


  Ok, I misunderstood you.

  I thought the processing from flv to jpeg would happen in the php script.
  So I think you still use ffmpeg on the second machine?

  Valentin

  Walter Tak schrieb: 
    It's pretty simple ; 

    See http://pastebin.com/m15ae8f99 for a PHP-function/script that downloads the file 

    The PHP function [copy] does the trick. (Had to figure out which function the ISP supported and in the end [copy] produces the lowest load on the server)

    Walter

      ----- Original Message ----- 
      From: Valentin Manthei 
      To: red5devs at osflash.org 
      Sent: Wednesday, 03 September 2008 15:10
      Subject: Re: [Red5devs] Taking a snapshot from a live video feed


      Hi Walter,

      your opinion fits with my thoughts about the heavy server load with many live streams at a time.
      I think about doing the processing in Red5, that would require a scheduling job and a deeper look at flv/jpeg data structure.

      Doing the processing on another machine like you described seems to be a nice solution, too. Are you so kind to post the php script if possible? That would help a lot.

      Best regards,
      Valentin

      Walter Tak schrieb: 
        Np,

        btw David uses ffmpeg on Red5 
:Process p =  Runtime.getRuntime().exec(this.FFMPEG+" -f 
flv -i - -vcodec png -vframes 1 -an -f rawvideo -s 160x120 
"+OUTPUTPATH+stream.getPublishedName()+".png");I've altered the class a bit a my app is calling a PHP-script ( using RemotingClient ) on another server which in order does the actual processing from FLV to JPG since I don't want to do the heavy ffmpeg processing on my expensive Red5 server.

        After the 1-frame FLV is extracted to a directory that's accessable via http (the jetty http server on 5080 or you could use tomcat or Apache to expose the directory) the php-script 'downloads' (using curl or fopen) the 1-frame-FLV from the Red5 server to the webserver (different physical machine, could also be located in a different country/datacentre).

        It isn't complicated and seperates the after-effects processing quite nicely.

        I didn't want to have 200 ffmpeg processes every 30 seconds running on a live-streaming Red5 server you see ; the webserver however is a cheap node that could be load balanced by adding a few more physical servers to do the conversion job, if it would be too much to be handled by 1 server.

        Walter




          Thanks for the hint, Walter. I haven't found that thread in my search before.
          http://osflash.org/pipermail/red5_osflash.org/2008-January/018263.html

          Valentin

          Walter Tak schrieb: 
Check the normal Red5 archives ; me and David Temes have discussed it and 
David made a 'snapshot' class which does exactly what you need ; it extracts 
a frame from the incoming FLV. You can convert that frame with ffmpeg 
(outside of Red5) to any fileformat like a JPG and use that 
snapshot/thumbnail to display on a frontpage for example to show ppl which 
livestreams are available and how they look like.

This does require some java-knowledge of (java/red5) schedulers , 
installation , compilation and execution of ffmpeg.

Subject "Re: [Red5] SnapshotListener" in January and February 2008.

Walter

  Hi everybody!

There are some topics about taking snapshots from a video stream on the
client using ActionScript 3, converting it into a ByteArray, encoding,
uploading, etc...

My question is about how to extract a jpeg image from a stream in the
Red5 server, better in the webapp itself.
The streams are published as "live", so there will be no file on the
disk I can operate with. Otherwise I would use ffmpeg to take a 
snapshot...

Is there a way to create a jpeg from the flv data in Red5? Where is the
point I have to start looking?

Thanks in advance,
Valentin

-- 
I am using the free version of SPAMfighter for home users.
SPAMfighter has removed 449 spam emails to date.
Paying users do not have this message in their emails.
Get the free SPAMfighter here: http://www.spamfighter.com/len
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/red5devs_osflash.org/attachments/20080903/95474821/attachment-0001.html 


More information about the Red5devs mailing list