简体   繁体   中英

Video Recording from Browser using Flash, PHP, Red5

I wish to build an application using which I can record video (along with audio) and also audio (only audio preferably in mp3 format).

From some research I did, I found I need a client app in flash or flex, a RTMP Server (RED5 preferable as its free)

This is the code which I used to get cam working flash.

var camera:Camera = Camera.getCamera();
var video:Video = new Video(); 
video.attachCamera(camera);
addChild(video);

The problem is, I don't know how to send the stream to RED5.

Also, what do I need to do so that I can store the video according to the user. The website I am creating is in PHP/MySQL and need to have their own videos and audios recorded. I love the way facebook has integrated Video Recording.

Check this: http://www.actionscript.org/resources/articles/615/2/Getting-started-with-red5-server/Page2.html

It explains how to connect and use RED5 and gives you an example.

Here's the exact AS3 code for publishing video from Flash to a media server like Red5, Wowza or AMS:

//init vars
public var nc:NetConnection;
public var ns:NetStream;

//net connection to media server
nc = new NetConnection();
nc.connect("rtmp://yourmediaserver/oflaDemo/instance");

//net stream through which the recording  data is sent
ns =  new NetStream(nc)

//attach cam and mic to net stream
ns.attachCamera(Camera.getCamera())
ns.attachAudio(Microphone.getMicrophone())

//send the data to the media server
ns.publish("streamName","record");

For just audio comment the ns.attachAudio line .

Flash Player can't encode mp3 sound (it can decode). You'll get sound encoded with NellyMoser ASAO. Speex is also an option. See this answer for more details.

oflaDemo is a Red5 app that supports video recording that's shipped with Red5.

For a (commercial) Flash/HTML video recording solution that supports Red5 and PHP you should check out https://hdfvr.com .

Also, what do I need to do so that I can store the video according to the user.

Just execute a PHP script (from the Flash client) that saves the info in the database. You can use POST or GET to send the video data and sessions or cookies to retrieve the user data.

var video:Video;
var camera:Camera = Camera.getCamera();
camera.addEventListener(ActivityEvent.ACTIVITY, active);
video = new Video();
video.attachCamera(camera);

function active(event:Event):void
 {
  addChild(video);
  camera.removeEventListener(ActivityEvent.ACTIVITY, active);
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM