安卓:录制和流媒体在同一时间 [英] Android: Recording and Streaming at the same time

查看:333
本文介绍了安卓:录制和流媒体在同一时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是不是真的,因为它是我所有的试图解决我所面临的最具挑战性的功能之一的presentation的问题。

This is not really a question as much as it is a presentation of all my attempts to solve one of the most challenging functionalities I was faced with.

我用 libstreaming 库流的实时视频到的 Wowza服务器,我需要在SD卡里面同时记录下来。我是为了收集新ideias从社区我所有的努力低于presenting。

I use libstreaming library to stream realtime videos to Wowza Server and I need to record it at the same time inside the SD card. I am presenting below all my attempts in order to collect new ideias from the community.

发展

我们在libstreaming库中的所有用户发送的字节复制到一个MP4文件中创建一个拦截。 Libstreaming通过LocalSocket发送字节Wowza服务器。它用户MediaRecorder访问摄像机和所述装置的麦克风和设置输出文件作为LocalSocket的输入流。我们要做的就是创建从周围延伸的InputStream此输入流的包装,并在里面创建一个文件输出流。所以,每次libstreaming执行读出在LocaSocket的输入流,我们所有的数据复制到输出流,试图建立一个有效的MP4文件。

We created an interception in libstreaming library to copy all the sent bytes to a mp4 file. Libstreaming sends the bytes to Wowza server through a LocalSocket. It users MediaRecorder to access the camera and the mic of the device and sets the output file as the LocalSocket's input stream. What we do is create a wrapper around this input stream extending from InputStream and create a File output stream inside it. So, every time libstreaming executes a reading over the LocaSocket's input stream, we copy all the data to the output stream, trying to create a valid MP4 file.

障碍

当我们试图读取该文件,它已损坏。我们意识到,有元信息从MP4文件丢失。具体的MOOV原子。我们试图拖延流的结束,以便给的时间来发送这个头(这仍然是一个猜测),但没有奏效。为了测试这个数据的连贯性,我们使用了付费软件来尝试恢复视频,包括报头。它成为了可玩的,但它主要是绿屏。因此,这成为了一个不值得信赖的解决方案。我们也尝试使用untrunc,一个免费的开源的命令行程序,它甚至无法启动恢复,因为没有MOOV原子。

When we tried to read the file, it is corrupted. We realized that there are meta information missing from the MP4 file. Specifically the moov atom. We tried to delay the closing of the streaming in order to give time to send this header (this was still a guessing) but it didn't work. To test the coherence of this data, we used a paid software to try to recover the video, including the header. It became playable, but it was mostly green screen. So this became an not trustable solution. We also tried using "untrunc", a free open source command line program and it couldn't even start the recovery, since there was no moov atom.

发展

FFMPEG有摇篮的插件使用Java接口来使用它里面的Andr​​oid应用程序。我们认为我们可以通过命令行访问摄像头(这大概是的/ dev / video0的),并将其发送到介质服务器。

FFMPEG has a gradle plugin with a java interface to use it inside Android apps. We thought we could access the camera via command line (it is probably in "/dev/video0") and sent it to the media server.

障碍

我们得到了错误权限被拒绝试图访问摄像头时。解决方法是将根设备能够访问它,但它让手机失去其保修,可以砖它们。

We got the error "Permission Denied" when trying to access the camera. The workaround would be to root the device to have access to it, but it make the phones loose their warranty and could brick them.

发展

我们试图让FFMPEG流通过MediaRecorder被记录在手机内的MP4文件

We tried to make FFMPEG stream a mp4 file being recorded inside the phone via MediaRecorder

障碍

FFMPEG不能流那些尚未与记录MP4文件

FFMPEG can not stream MP4 files that are not yet done with the recording.

发展

Libstreaming使用LocalServerSocket为应用程序和服务器之间的连接,所以我们认为我们可以使用的ffmpeg与LocalServerSocket本地连接地址直接复制分流到SD卡内的本地文件。流开始紧接着,我们也跑了FFmpeg的命令来启动数据记录到文件中。使用的ffmpeg,我们认为这将创造适当的方式MP4文件,这意味着与包括MOOV原子头。

Libstreaming uses LocalServerSocket as the connection between the app and the server, so we thought that we could use ffmpeg connected with LocalServerSocket local address to copy the streaming directly to a local file inside the SD card. Right after the streaming started, we also ran the ffmpeg command to start recording the data to a file. Using ffmpeg, we believed that it would create a MP4 file in the proper way, which means with the moov atom header included.

障碍

创建的地址是不通过命令行可读,作为在手机内的本地地址。因此复制是不可能的。

The "address" created is not readable via command line, as a local address inside the phone. So the copy is not possible.

发展

的OpenCV是一个开源,跨平台的库,提供构建模块,计算机视觉实验和应用。它提供了高层次的接口,用于捕获,处理和presenting图像数据。它有自己的API与设备连接相机,所以我们开始天花板高度它,看它是否有必要的功能流和记录在同一时间。

OpenCV is an open-source, cross-platform library that provides building blocks for computer vision experiments and applications. It offers high-level interfaces for capturing, processing, and presenting image data. It has their own APIs to connect with the device camera so we started studding it to see if it had the necessary functionalities to stream and record at the same time.

障碍

我们发现,图书馆是不是真的确定要做到这一点,但更多的是像数学运算。我们甚至得到了推荐使用libstreaming(我们做的话)。

We found out that the library is not really defined to do this, but more as image mathematical manipulation. We got even the recommendation to use libstreaming (which we do already).

发展

Kickflip是一个流媒体服务,提供他们自己的SDK为开发Android和iOS。它还使用HLS代替RTMP,这是一种较新的协议

Kickflip is a media streaming service that provides their own SDK for development in android and IOS. It also uses HLS instead of RTMP, which is a newer protocol.

障碍

他们的SDK要求我们创建具有占据设备的整个屏幕,打破了我们的应用程序的可用性摄像机视图一个活动。

Their SDK requires that we create a Activity with camera view that occupies the entire screen of the device, breaking the usability of our app.

发展

我们开始咨询的应用程序的其他开发人员在Play商店已经上市,该流的服务器了。

We started consulting other developers of app's already available in the Play Store, that stream to servers already.

障碍

获得与那些开发联系,他们保证,就不可能使用该技术同时记录和流。更重要的是,我们将不得不使用Adobe AIR的从头重做整个应用程序。

Getting in touch with those developers, they reassured that would not be possible to record and stream at the same time using this technology. What's more, we would have to redo the entire app from scratch using Adobe Air.

推荐答案

一旦OpenCV的3.0可(在RC1可以下载<一个href="http://sourceforge.net/projects/opencvlibrary/files/opencv-android/3.0.0-rc1/OpenCV-3.0.0-rc1-android-sdk-1.zip/download"相对=nofollow>此处),我们可以添加另一个选项列表:

As soon as OpenCV 3.0 is available (the RC1 can be downloaded here), we could add another option to this list:

使用OpenCV的内置的 MOTION- JPEG EN codeR

Using OpenCV's built in Motion-JPEG encoder

这篇关于安卓:录制和流媒体在同一时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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