从Android的音频和视频流,以PC /网络。音频、视频、网络、Android

2023-09-05 08:20:20 作者:我的抄小公主

我最近刚使用Android SDK中,而这个项目的总体目标是创建一个应用程序非常相似,USTREAM的或Qik的的(是的,我不知道对于初学者最好的主意)。我需要传输实时音频和视频传到网上。会有一个视频服务器,最有可能使用Wowza,处理的视频,以适当的格式的编码。

I am recent beginner to Android SDK, and the overall goal of this project is to create an app very similar to Ustream's or Qik's (yeah, I know not the best idea for a beginner). I need to stream live audio and video to the web. There will be a video server, most likely using Wowza, handling the encoding of the videos to the proper format.

从我发现至今,我需要使用Android的MediaRecorder用相机作为源,直接输出到服务器。这对我来说很有意义,但我不知道如何去这样做。谁能给我推在正确的方向?我已经经历了一个例子,在HTTP://ipcamera-for-android.google$c$c.com/svn/trunk浏览,但似乎远远超过必要的复杂,我需要做的,我有一直无法得到它在Eclipse工作反正来测试它。

From what I have found so far, I need to use android's MediaRecorder with the camera as the source and direct the output to the server. That makes sense to me, but I do not know exactly how to go about doing that. Can anyone give me a push in the right direction? I have browsed through an example at "http://ipcamera-for-android.googlecode.com/svn/trunk", but that appears to be far more complicated than necessary for what I need to do and I have been unable to get it working in eclipse to test it anyway.

推荐答案

这样做并不简单,但可能的。

Doing so is not simple but possible.

的MediaRecorder API假设的输出是随机访问文件,也就是说,它可以得到来回用于写入MP4(或其它)文件容器。 正如你可以在IPCAMERA换机器人看到,输出文件被引导到一个插座,是不是随机访问。 事实上使得它很难解析输出流,因为只有当记录完成的MediaRecorder API将写之类的FPS,SPS / PPS(对H264)的一些数据等。该API将试图寻求回流(这里文件头存在)的开始,但它会失败,因为流发送到一个插座,而不是一个文件。

The MediaRecorder API assumes that the output is a random access file, meaning, it can got forth and back for writing the mp4 (or other) file container. As you can see in the ipcamera-for-android, the output file is directed to a socket which is not random access. The fact makes it hard to parse the outgoing stream since the MediaRecorder API will "write" some data like fps, sps/pps (on h264) and so on only when the recording is done. The API will try to seek back to the beginning of the stream (where the file header exists) but it will fail since the stream is sent to a socket and not to a file.

服用IPCAMERA换Android是一个很好的参考,如果我没有记错,流之前,它记录了一个视频文件,打开头,并采取它从那里需要的,不是,它开始记录到插座和使用它从标题接过数据以解析流

Taking the ipcamera-for-android is a good reference, if I recall correctly, before streaming, it records a video to a file, opens the header and takes what it needs from there, than, it start recording to the socket and uses the data it took from the header in order to parse the stream.

您还需要一些基本的认识,解析MP4(或你想使用其他文件格式),以捕捉帧。 你可以做到这一点无论是在设备或服务器端。

You will also need some basic understanding in parsing mp4 (or other file container you'd want to use) in order to capture the frames. You can do that either on the device or on the server side.

下面是一个良好的开端写入流套接字: Tutorial

Here is a good start for writing the stream to a socket: Tutorial

我希望这是有帮助的,有没有好的教程解析和输出流进行解码,因为它不是那么简单......但同样,有可能与一些努力。

I hope it was helpful, there is no good tutorial for parsing and decoding the outgoing streams since it is not so simple...but again, it is possible with some effort.

看看这里还看到如何直接输出流可以发送到服务器的数据流: MediaRecorder问

Take a look also here to see how to direct the output stream to a stream that can be sent to the server: MediaRecorder Question