如何使用 Flex 将视频流发送到 Red5 服务器?

发布于 2024-09-07 22:46:42 字数 2466 浏览 6 评论 0原文

我正在尝试使用 Flex 将视频流发送到 Red5 服务器。

我的 Red5 设置似乎适用于远程方法调用和共享对象,但我尚未成功使视频正常工作。

这是连接到 Red5 的 AS3 代码:

# 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)

当收到 NetConnection.Connect.Success 时,运行以下代码以开始发送流:

# 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());

但是,这不起作用,所以我做错了。

这是绑定到我要连接的 Red5 上下文的 Java 应用程序:

package com.company;

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

我正在运行 Red5 0.9.1,我所做的唯一配置是通过编辑 WEB-INF/red5-web 来设置我的应用程序。 xml 并添加:

<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">
     <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" />

这些是我在连接并尝试发送视频时在 Red5 控制台中收到的日志消息:

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

我做错了什么?如前所述,请注意,Red5 设置对于远程方法调用和共享对象来说可以完美地工作,但对于视频来说就不行了,这很奇怪。

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">
     <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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅笑依然 2024-09-14 22:46:42

你的配置/类中没有任何内容让我感到惊讶,一切看起来都不错。您是否尝试过发布到其中一个演示只是为了排除您的客户? ofla演示还是现场直播?

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?

Hello爱情风 2024-09-14 22:46:42

只是一个想法,但您知道您的相机使用什么编解码器吗?

我已经成功创建了一个简单的 Flex 应用程序运行到 Red5 示例服务器应用程序,据我所知,它所做的与您所做的几乎相同。

如果将“实时”更改为“记录”,是否会在服务器应用程序的流目录中保存任何内容?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文