使用XUGGLER写入RTMP流

时间:2012-10-02 07:32:10

标签: red5 rtmp xuggler

我正在开发一个项目,我想将数据包写入RTMP容器。

  • 我所取得的成就是:

    1. 启动使用RED5侦听RTMP请求的应用。让我们说rtmp:// localhost / myapp
    2. 我可以用IContainerFormat的输出格式打开IContainer(“flv”,“rtmp:// localhost / myapp / test”,null)
  • 出现问题的是:

    1. 我想将数据包写入为我打开的RTMP频道。
      • 问题是FFMPEG开始给出错误32.与此错误相关的一些搜索显示,这通常是因为客户端 - 服务器数据消耗之间存在延迟。但我真的无法解决这个问题。我经常搜索,但每个人都在为同一个问题哭泣。我得到的错误是:
  

12:57:20.242 [Thread-0] ERROR org.ffmpeg - WriteN,RTMP发送错误32(129字节)       12:57:20.246 [Thread-0] ERROR org.ffmpeg - WriteN,RTMP发送错误32(45字节)       12:57:20.246 [Thread-0] ERROR org.ffmpeg - WriteN,RTMP发送错误9(42字节)

这是我在Red5服务器上收到的错误

[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider connect
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Stream start
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider connect
[ERROR] [NioProcessor-1] org.red5.server.net.rtmp.codec.RTMPProtocolDecoder - Error decoding buffer
org.red5.server.net.protocol.ProtocolException: Error during decoding
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decode(RTMPProtocolDecoder.java:203) [red5.jar:na]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeBuffer(RTMPProtocolDecoder.java:122) [red5.jar:na]
    at org.red5.server.net.rtmp.codec.RTMPMinaProtocolDecoder.decode(RTMPMinaProtocolDecoder.java:61) [red5.jar:na]
    at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:225) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:638) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:598) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:587) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:61) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:969) [mina-core-2.0.0-RC1.jar:na]
    at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [mina-core-2.0.0-RC1.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_07]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_07]
    at java.lang.Thread.run(Unknown Source) [na:1.7.0_07]
Caused by: java.lang.IllegalArgumentException: null
    at java.nio.Buffer.limit(Unknown Source) [na:1.7.0_07]
    at org.red5.io.amf.Input.bufferToString(Input.java:275) [red5.jar:na]
    at org.red5.io.amf.Input.getString(Input.java:258) [red5.jar:na]
    at org.red5.io.amf.Input.readPropertyName(Input.java:565) [red5.jar:na]
    at org.red5.io.amf.Input.readKeyValues(Input.java:351) [red5.jar:na]
    at org.red5.io.amf.Input.readSimpleObject(Input.java:501) [red5.jar:na]
    at org.red5.io.amf.Input.readObject(Input.java:537) [red5.jar:na]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeStreamMetadata(RTMPProtocolDecoder.java:978) [red5.jar:na]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeMessage(RTMPProtocolDecoder.java:564) [red5.jar:na]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodePacket(RTMPProtocolDecoder.java:385) [red5.jar:na]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decode(RTMPProtocolDecoder.java:190) [red5.jar:na]
    ... 18 common frames omitted
[WARN] [NioProcessor-1] org.red5.server.net.rtmp.codec.RTMPProtocolDecoder - Closing connection because decoding failed: RTMPMinaConnection from 127.0.0.1 : 44814 to localhost (in: 3569 out 3521 )
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Close
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider disconnect
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider disconnect
[INFO] [NioProcessor-1] org.red5.server.net.rtmp.RTMPHandler - Connecting to: [Scope@5f524524 Depth = 2, Path = '/default/myapp', Name = 'test']
[INFO] [NioProcessor-1] org.red5.server.net.rtmp.RTMPHandler - Remembering client buffer on stream: 300
[ERROR] [NioProcessor-1] org.red5.server.service.ServiceInvoker - Method FCSubscribe with parameters [teststream] not found in org.red5.core.Application@b9e19da
[WARN] [NioProcessor-1] org.red5.server.stream.PlayEngine - Subscribe to teststream provider failed

我是媒体流媒体的新手,所以不确定我是否遗漏了某些东西。

提前致谢。

2 个答案:

答案 0 :(得分:0)

我认为调试RTMPProtocolDecoder的Java源代码的可能性不大。

但我不知道你正在使用什么Red5版本。

RTMPProtocolDecoder.java:203 =>在最新版本的Red5 / Sources中,您的例外情况在第147行: http://code.google.com/p/red5/source/browse/java/server/trunk/src/org/red5/server/net/rtmp/codec/RTMPProtocolDecoder.java#147

还添加了一些评论。我想你需要做的第一件事是更新到最新的red5。在此基础上,您可以调试并寻求更多帮助。

答案 1 :(得分:0)

只是为了完成答案。不要依赖Red5 eclipse插件,它会生成与Red 5 1.0RC2不兼容的代码。 Red5 1.0 RC 2在red5-web.xml中配置更改时工作正常。应用程序开始工作,我可以使用xuggler在容器上启动流。

谢谢@ seba.wagner。