Video Recording from Browser using Flash, PHP, Red5

天涯浪子 提交于 2019-12-07 10:05:07

问题


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.


回答1:


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.




回答2:


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.




回答3:


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);
 }


来源:https://stackoverflow.com/questions/7933221/video-recording-from-browser-using-flash-php-red5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!