Legal
The views expressed in this blog are my own and do not necessarily reflect the views of Adobe Systems Incorporated.
Search
June 09, 2006
Record Video From Webcam and Post To Drupal (With Source Code)
For my talk to the Boston PHP user group last week, I built on Chritophe's sample that showed recording video from a webcam, and then publishing that to a Drupal based blog. Here is the code (MXML Format). To get this running, you'll need a copy of Flash Media Server (free developer version available) and a working webcam (I'm not really into error checking :) ). Once you download and install Flash Media Server, in C:\Program Files\Macromedia\Flash Media Server 2\applications\, create a directory called flex_videoconference. A few things to note:
In the source, you'll see:
nc = new NetConnection();
nc.objectEncoding = flash.net.ObjectEncoding.AMF0;
nc.connect( "rtmp:/flex_videoconference");
You need the line ...=flash.net.ObjectEncoding.AMF0 because FMS doesn't do AMF3. The line nc.connect("rtmp:/flex_videoconference"); is equivalent to nc.connect("rtmp://localhost/flex_videoconference"); so if you're connecting to a remote server, you'll want to change localhost, obviously.
The line nsPublish.publish("christophe", "record"); tells FMS to record the stream so you can play it back. Valid values are "record", "append", and "live". The default value is "live". (Lookup NetStream in the Flex help for more information).
Nearly everything works in the publishing method, but I can't figure out how to properly encode the HTML string being sent to Drupal so that it will display the movie properly. I have also created a MediaPlayer.swf video player and put that in my Drupal theme directory, but because I can't get the encoding working properly, then it doesn't matter. If you have knowledge of the BlogAPI for Drupal, please help!
Regardless, even if you don't use it, you've got a way to record video to Flash Media Server and then to play it back in a simple example.
Comments
Could you please wrap the code in a code tag? :)
Thank you for signing in, You may now comment. (Sign Out)
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)