Using Flash Media Server (FMS) with RTMP for live video chat

8.6k views Asked by At

I am trying to get a very basic example of live video chat to work with Flash Media Server, but no matter how hard I try, it's just not working for me.

I am using the tutorial and code from this web page: http://www.derekentringer.com/blog/fms-video-chat/

I have two servers: a web server, and media server. On the media server, I have FMS installed and I made sure that port 1935 was opened up to communicate between the web and media server.

I think my issue is how to set up my FMS instance. In the tutorial, he's using a hosted FMS solution with Influxis.com. I am using my own media server with FMS installed. Does anyone know how to set up my FMS instance so I can get this to work?

On the web server, I have two different folders (user1 and user2) each with an html file and a swf file to connect to the web cam, and then connect the web cam's stream to the media server over rtmp.

Here's the code I have on the SWF files.

//setup the camera and mic for streaming
mycam = Camera.get();
mycam_audio = Microphone.get();

//control the cameras mode and quality
mycam.setMode(320,240,30);
mycam.setQuality(10000,100);

//attach a live preview of the camera to the 
//video object that is setup on the stage
cam_feed.attachVideo(mycam);
cam_feed.attachAudio(mycam_audio);

//connect to the Flash Media Server
client_nc = new NetConnection();
client_nc.connect("rtmp://corpwebdevmedia1/test"); // I've tried server name and IP
cam_ns = new NetStream(client_nc);

//attach our camera video and audio to the net stream
cam_ns.attachVideo(mycam);
cam_ns.attachAudio(mycam_audio);

//publish to our Flash Media Server as a 
//live stream called user_2
cam_ns.publish("user_2", "live");
// user_1 for the other one

//bring in user_1's video/audio
in_ns = new NetStream(client_nc);
in_ns.play("user_1");  
// user_2 for the other one

//attach user_1's published audio and video
//so we can see them in the larger chat window
live_feed.attachVideo(in_ns);
live_feed.attachAudio(in_ns);

After all that's done, I go to my local machine and navigate my browser to the html files on the web server. The page connects to my camera on each page, but they never connect together.

Any suggestions?

Thanks.

1

There are 1 answers

0
Kipras On BEST ANSWER

I'm not sure if this is true for all cameras, but at least when i was developing a similar application, i ran into the same issue, and the cause of the problem was that two applications cannot share the same camera.

In other words, you can't videochat with Skype, and with a flash player application at the same time. The same is true for two flash player applications - they can't both use the same camera input. So try to connect another camera, or test with two pc's (that's what i did). If you test with a single system, you will have even more problems with audio settings (though i can't exactly remember what was wrong, but i did have many issues with trying to mute or change audio volume, when trying to simulate a full 2 person chat on one system)

Another problem may be that you are using the same stream name for both applications, did you switch "user_2" and "user_1" around in one of the applications ?