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

Post a comment