开发者

How do I send a video stream to a Red5 server using Flex?

I'm trying to send a video stream to a Red5 server using Flex.

My Red5 setup seems to work for remote method invocations and shared objects, but I've yet to succeed in getting video working.

This is the AS3 code that connects to Red5:

# connect to RTMP server
netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
netConnection.connect("rtmp://localhost/context_name");
# omitted code for waiting for connection success, and setting up shared
# objects (which works fine - the Red5 setup is hence OK)

And when NetConnection.Connect.Success is received the following code is run to start sending the stream:

# when NetConnection.Connect.Success then the following code is run:
var netStream:NetStream = new NetStream(netConnection);
netStream.publish("name_of_stream", "live");
netStream.attachCamera(Camera.getCamera());

However, this does not work so I'm doing something wrong.

This is the Java application bound to the Red5 context I'm connecting to:

package com.company;

public class NameOfApplication extends ApplicationAdapter {
    // Empty class.
}

I'm running Red5 0.9.1 and the only configuration I've done is setting up my application by editing WEB-INF/red5-web.xml and adding:

<bean id="context_name.context" class="org.red5.server.Context" autowire="byType" />
<bean id="context_name.scope" class="org.red5.server.WebScope" init-method="register">
     <开发者_JAVA技巧property name="server" ref="red5.server" />
     <property name="parent" ref="global.scope" />
     <property name="context" ref="context_name.context" />
     <property name="handler" ref="context_name.handler" />
     <property name="contextPath" value="/context_name" />
     <property name="virtualHosts" value="*,localhost, localhost:5080, 127.0.0.1:5080" />                  
 </bean>
 <bean id="context_name.handler" class="com.company.NameOfApplication" />

These are the log messages I get in the Red5 console while connecting and trying to send video:

org.red5.server.net.rtmp.RTMPHandler - Connecting to: [WebScope@68e0ada6 Depth = 1, Path = '/default', Name = 'application_name']
org.red5.server.net.rtmp.RTMPHandler - Remembering client buffer on stream: 0
org.red5.server.stream.ClientBroadcastStream - Provider connect
org.red5.server.stream.ClientBroadcastStream - Stream start
org.red5.server.stream.ClientBroadcastStream - Provider connect
org.red5.server.stream.ClientBroadcastStream - Close
org.red5.server.stream.ClientBroadcastStream - Provider disconnect
org.red5.server.stream.ClientBroadcastStream - Provider disconnect

What am I doing wrong? As said, please note that the Red5 setup works flawlessly for remote method invocations and shared objects, but not for video which is strange.


Nothing jumps out at me from your configs/classes, it all looks ok. Have you tried publishing to one of the demos just to rule out your client? oflaDemo or live?


Just a thought but do you know what codec your camera is using?

I've managed to get a simple Flex app up & running to a Red5 sample server app and from what I can tell was doing pretty much the same as you've done.

If you change "live" to "record" does anything get saved in the streams directory of your server app?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜