流从Android手机的音频和视频到RTMP服务器的最佳方法 [英] Best way to stream audio and video from an Android phone to a RTMP server

查看:753
本文介绍了流从Android手机的音频和视频到RTMP服务器的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找视频流和音频的Andr​​oid手机使用RTMP服务器的最佳方式。我花了一些时间对这个问题,这一步我已经能够仅使用FFMPEG的视频流。有很多种方法来建立的lib Android和我想这与一些更多的工作,我应该能够传输音频了。

I'm looking for the best way to stream video and audio from an Android phone to a server using RTMP. I've spent some time on this problem and this far I've been able to stream video only using FFMPEG. There are many ways to build the lib for Android and I guess that with some more work I should be able to stream Audio too.

的事情是,我需要连接code的H264视频和AAC音频,而这将是非常容易使用Android的的 MediaRecorder 。于是我开始寻找RTMP库为Android,发现这 Red5的端口,这似乎是工作pretty的好。使用它,我可以将存放在手机上很容易的视频文件,音频是工作压力太大。

The thing is that I need to encode the video in h264 and the audio in AAC, and it would be very easy to do it using Android's MediaRecorder. So I started looking for a RTMP library for Android and found this Red5 port that seems to be working pretty well. Using it I can stream a video file stored on the phone very easily, and the audio is working too.

所以我的问题是:有没有办法来Android的MediaRecorder输出连接到RTMP库?我想的办法是假的一中setOutputFile(文件),然后将数据发送给RTMP编码方法,但我想不出一个办法做到这一点。

So my question is the following: Is there a way to connect Android's MediaRecorder output to the RTMP library? I guess the way would be to 'fake' a file in setOutputFile(), and then to send the data to the RTMP encoding methods, but I can't figure a way to do it.

任何线索是值得欢迎的,真的。提前致谢。

Any clue is welcome, really. Thanks in advance.

推荐答案

您可以将数据写入到的的FileDescriptor ,而不是与setOutputFile()。文件

you are able to write the data to a FileDescriptor instead of a file with setOutputFile().

FileDescriptor fd = mLocalSender.getFileDescriptor();
mRecorder.setOutputFile(fd);

这样你就可以将数据传输到一个插座。从这个套接字获取数据是这样的:

so you can stream the data to a socket. to get the data from this socket looks like this:

mLocalServer = new LocalServerSocket(LOCAL_SOCKET_ADDRESS);

mLocalReceiver = new LocalSocket();
mLocalReceiver.connect(new LocalSocketAddress(LOCAL_SOCKET_ADDRESS));

mLocalSender = mLocalServer.accept();

if (mLocalReceiver != null)
{
    mInputStream = mLocalReceiver.getInputStream();
}

我不知道你的RTMP库工作,但我认为,它应该是可能的输入流传递到库的一些方法。

i don't know how your RTMP library is working, but i think, it should be possible to pass the input stream to some methods of the library.

有关更多信息,您还可以检查出href="http://$c$c.google.com/p/spydroid-ipcamera/" rel="nofollow"> spydroid应用的

for further information you also can check out the spydroid application. it includes a lot of useful stuff for video streaming over RTP without any special streaming libraries.

这篇关于流从Android手机的音频和视频到RTMP服务器的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆