IP Camera to FMS Flash Video Howto (OSX)

OVERVIEW;

[jump to the code page here]

A HowTo for getting IP Camera video into FMS, Wowza, Red5 or other Flash Media Server equivalent systems.

  • Why?

A few reasons;

- Because Flash only supports USB Webcams, which are typically of low quality.

- It is possible to do pre-processing on the images before serving them ‘to flash for broadcasting’ such as Watermarking, Picture-in-Picture (multiple cameras to one feed), Overlays and so on triggered by external events or commands.

- USB Webcams need to be wired in close proximity to the broadcasting computer. Now you can use any network camera, wireless or wired!

- You can now use cameras with changeable lenses for higher quality or application specific purposes

- PTZ Cameras can now be rebroadcast in high quality and with simple Flash controls

  • Operating System;

I have made this for Mac OSX (tested with Leopard and Snow Leopard), as this is my preferred platform however there is no reason this could not be accomplished on Windows or Linux. I have done this on Linux already, but not on Windows myself : although i have seen plenty of sample code around the internet for creating virtual webcam drivers for XP+, just never tried it (nor would i want to).

  • Stability;

The following method is running solidly from 6 broadcast locations, 24/7 without user intervention and without a single crash or memory leak or any problems whatsoever, and has been up live for over 18 months in production.

  • Demonstration;

You can see the demonstration of this platform for which this was originally created here at this link: http://demo.lyvegame.com (Live Casino Broadcasting, click on ‘roulette 1′ or ‘roulette 2′ to see the live video).

  • Speed;

I get between 15 and 30 FPS depending on the brand of camera and quality/resolution i choose to capture from. I have noticed some Network Cameras have quite a slow CPU, and if more than one script/client is connected to the camera itself on your LAN that the framerate slows down significantly. So remember, 1x script to connect to each camera : and use a FMS/Wowza/Red5 server (or CDN service) for any rebroadcasting you want to do.

  • Functionality;

For the purpose of keeping this HOWTO simple, i have removed all options for dynamic resolution, quality, overlays, picture-in-picture and external event source camera switching and animating functions; however all of these are possible, and in my production systems are in place quite happily. This version can be run in multiple instances, allowing you to capture and rebroadcast upto 3 network cameras at once, all available to Flash as 3 independent ‘webcams’.

  • Camera Support;

So expect the below scripts to be hard-coded for 320×240 resolution, working and tested with the following cameras;

- Sony RX-550[x] : Sony PTZ Network Camera
- Sony SNC-CS11 : IPELA PROGRESSIVE SCAN FIXED IP CAMERA JPEG/MPEG4 POE
- Axis  : 211/M
- Axis :  212/M PTZ
- Rovio : exact model unknown
- Foscam : exact model unkown
- ACTi : ACM-4201

- easy to ADD new types, once defining data –boundary and mjpeg URL specifics (must test camera data output to discover these : i simply use ‘telnet’)

  • The Components;

- the FrameGrabber;
I use a Python script for this, which connects to the camera and pulls apart an MJPEG stream into seperate JPEG images on the fly, saving them into a ramdisk location successively.

- the Camera Virtualizer;
This is a QuickTime Component/Virtual Camera Driver which reads the JPEG’s from the ramdrive and creates a Virtual Webcam appear to be plugged into the Operating System (OSX 10.5+). This way the video may be captured as a webcam from any Flash Application such as JustinTV, YouTube Recording, UStream.TV, your own Flash Application, Skype, MSN or any other webcam compatible application.

- the StartUp Scripts;
These are setup to create the prerequisites to running the above, such as creating a ramdrive in a predetermined location, creating framebuffer files in that location, and launching the Python script in the background (as a screen session). So that all this takes place without user intervention or user interface (completely transparent to the user and the OS).

So, without further ado, lets begin: GOTO THE CODE

Comments

  • lior says:
    6-06-10

    hi, our ebsite want to streaming live + on demand lectures . but we want to record the streaming on the server live .
    which (HD) camera we need?
    and which server and platform can u suggest us?
    thanks for help from your knowledge..
    Lior

  • alex says:
    6-06-10

    hi lior,

    you can use any camera for that, it does not need to be an IP camera as you can install ‘adobe flash media live encoder’ (free download from adobe.com), and use it to broadcast any USB/firewire camera to an FMS server online.
    You can use an IP camera if you want, but the setup is more complicated, and im judging by your questions it might be beyond your skills.

    Then on the FMS server, which i myself prefer to run on Linux (specifically Ubuntu), you can code a simple DVR functionality and live playback. Infact Adobe FMS comes with examples of how to do this.

    You can also run Red5 or Wowza (maybe there are others), but my preference is Adobe, i have tried the others, i hate java, and i always encounter bugs so i stick with Adobe.

    Hope this helps.

    Alex.

  • lior says:
    6-06-10

    thanks for reply. I forgot to say but I don’t want any computer in the lecture room. so I thought maybe I need IP camera that will stream directly to some flash server.
    and the server will record it automaticly.
    and after that I’ll just need to link from my website to the recorded file saved on server.
    what u say?

  • alex says:
    6-06-10

    hi lior
    that is a totally different solution than i am offering or talking about here.
    for that i have read the latest Wowza media server (another version or alternative to adobe FMS) has the ability to grab video from IP cameras (i read that AXIS cameras are best for this), transcode and rebroadcast and/or record them in DVR mode which is what you want.

    so, it looks like you can use an off the shelf solution, investigate Wowza. Personally i dont like it much, i had a lot of stability issues in my own Wowza experience.

    also you will need some basic java coding to set it up the way that you want, though i think what your asking is common or simple enough that it may be included in their packaged examples.

    Alex.

  • lior says:
    6-06-10

    thanks, U realy help.
    I gonna try Wowza
    bye

Post a comment