Skip to main content
December 7, 2011
Question

Uploading a webcam feed for processing, not publishing.

  • December 7, 2011
  • 1 reply
  • 2232 views

Hello, I'm trying to use Flash Media Server (on Amazon) to read in a video feed from a user's webcam, process it via my own executable, and return processed data (not video) to the user.

For simplicity, let's say my executable finds the darkest pixel in the image and returns its coordinates, and I want the client to draw a cross at this location.

The client-side is working fine. It can send the video stream, and receive vertex data to draw. The server is half-working. It can accept connections, and send fake vertex data to the client. However I can't find any way to access the webcam stream.

Ideally, I would pass each frame from the stream into my executable for processing, with no saving to disk (or perhaps minimal saving to disk as a cache for P-frames). I've got the impression that this is impossible though, so another acceptable solution is to save the stream (live) to disk, and read it (live) from my executable.

I'm a bit stuck with both approaches, so any pointers would be greatly appreciated.

Also, somewhat relatedly, I would like to secure the video feed as much as possible. Eventually I'll use SSL to secure it in transit, but for now I have the more serious problem of FMS sharing every stream it recieves. I'm sure there's an option to disable this somewhere, but I just can't find it.

This topic has been closed for replies.

1 reply

December 8, 2011

Ok, I've reduced this to the problem of running ffmpeg for each connection (ffmpeg can pipe each frame to my app thanks to this site

http://www.drmaciver.com/2010/12/reading-video-frame-by-frame-with-ffmpeg/, although, like him, I would prefer to use the actual API).

Would the C++ File plugin be able to do this? As in, when FMS tries to record a stream to disk, my file plugin could call ffmpeg with the data instead. I need it to be able to process the data near-live and would rather not have anything saved to disk at all. Also I need to have some kind of feedback mechanism (to send back the data) and I don't think this is possible with the file plugin's archetecture.

I've only just found out about these plugins, so if anybody can let me know if they'll do what I need I would be greatful. I'd like to avoid spending hours learning how to use them if they turn out to be useless!

December 12, 2011

AFAIK, there is no API (javascript or C++) that will give you access to the raw stream data in FMS.

If I was tasked with this project, I'd opt to use Wowza. Wowza provides an API that gives you access to the raw stream data, so you can catch your frames and pass them into FFMPEG for decoding.

Since wowza runs on Java, you could also take advantage of the Xuggler libraries, which provides a JNI interface and Java API to the FFMPEG binary.

December 13, 2011

Thanks for the heads up. If fms gets too mind-bending I'll take a look at it.

I've actually managed to get the data now, through the fileio plugin (tricking fms into thinking it's writing to disk when it's actually sending the data to ffmpeg). It's not ideal because so far it can only cope with a single stream, but I should be able to fix that (turns out fms opens and closes the file regularly. I was hoping to use the open/close to start/stop ffmpeg processes, but I'll have to find another way).

The new problem is that flash uses some unusual mp4 file format, which ffmpeg doesn't recognise. I know that adobe offers a converter, but from what I've seen it only works on complete files, and I need streaming.

So I suppose my new question is how do I read frames from fms's mp4s?

(I also still don't have a good way to send the data back. The best I've thought of so far is to do the same again; start a fake file read and stream the data from that, so if anyone has any better ideas they are appreciated)