Android 将视频输入流转换为 RTMP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10123498/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:34:43  来源:igfitidea点击:

Convert video Input Stream to RTMP

androidvideostreamingrtprtmp

提问by Marko

I want to stream video recording from my android phone to network media server.

我想将视频录制从我的 android 手机流式传输到网络媒体服务器。

The first problem is that when setting MediaRecorderoutput to socket, the stream is missing some mdatsize headers. This can be fixed by preprocessing that stream locally and adding missing data to stream in order to produce valid output stream.

第一个问题是,当将MediaRecorder输出设置为套接字时,流缺少一些mdat大小的标头。这可以通过在本地预处理该流并将丢失的数据添加到流中以生成有效的输出流来解决。

The question is how to proceed from there.

问题是如何从那里开始。

How can I go about output that stream as an RTMP stream?

如何将该流输出为 RTMP 流?

回答by MrGomez

First, let's unwind your question. As you've surmised, RTMPisn't currently supported by Android. You can use a few side librariesto add support, but these may not be full implementations or have other undesirable side effects and bugs that cause them to fail to meet your needs.

首先,让我们解开你的问题。正如您所猜测的,Android 目前不支持RTMP。您可以使用一些辅助库来添加支持,但这些可能不是完整的实现或具有其他不良副作用和错误,导致它们无法满足您的需求。

The common alternativein this case is to use RTSP. It provides a comparable session format that has its own RFC, and its packet structure when combined with RTP is very similar (sans some details) to your desired protocol. You could perform the necessary fixups here to transmute RTP/RTSP into RTMP, but as mentioned, such effort is currently outside the development scope of your application.

在这种情况下,常见的替代方法是使用RTSP。它提供了一个类似的会话格式,它有自己的 RFC,并且它与 RTP 结合时的数据包结构与您想要的协议非常相似(没有一些细节)。您可以在此处执行必要的修复以将 RTP/RTSP 转换为 RTMP,但如前所述,此类工作目前超出了您的应用程序的开发范围。

So, let's assume you would like to use RTMP (invalidating this thread) and that the above-linked librarydoes not meet your needs.

因此,让我们假设您想使用 RTMP(使该线程无效)并且上面链接的库不能满足您的需求。

You could, for example, follow this tutorialfor recording and playback using Livu, Wowza, and Adobe Flash Player, talking with the Livu developer(s)about licensing their client. Or, you could use this client libraryand its full Android recorder exampleto build your client.

例如,您可以按照本教程使用 Livu、Wowza 和 Adob​​e Flash Player 进行录制和播放,并与Livu 开发人员讨论许可其客户的事宜。或者,您可以使用此客户端库及其完整的Android 记录器示例来构建您的客户端。

To summarize:

总结一下:

RTSP

实时服务提供商

RTMP

RTMP

Best of luck with your application. I admit that I have a less than comprehensive understanding of all of these libraries, but these appear to be the standard solutions in this space at the time of this writing.

祝您申请顺利。我承认我对所有这些库的理解不够全面,但在撰写本文时,这些似乎是该领域的标准解决方案。

Edit:

编辑:

According to the OP, walking the RTMP library set:

根据OP,走RTMP库集:

In short: more work is needed. Other answers, and improvements upon these examples, are what's needed here.

简而言之:需要做更多的工作。此处需要其他答案以及对这些示例的改进。

回答by eeKat88

If you are using a web-browser on Android device, you can use WebRTC for video capturing and server-side recording, i.e with Web Call Server 4

如果您在 Android 设备上使用网络浏览器,则可以使用 WebRTC 进行视频捕获和服务器端录制,即使用Web Call Server 4

Thus the full path would be:

因此,完整路径将是:

Android Chrome [WebRTC] > WCS4 > recording

Android Chrome [WebRTC] > WCS4 > 录音

So you don't need RTMP protocol here.

所以你在这里不需要 RTMP 协议。

If you are using a standalone RTMP app, you can use any RTMP server for video recording. As i know Wowza supports H.264+Speex recording.

如果您使用的是独立的 RTMP 应用程序,则可以使用任何 RTMP 服务器进行视频录制。据我所知,Wowza 支持 H.264+Speex 录音。