如何上传从(N的Andr​​oid)手机的视频,因为它是被记录 [英] How to upload video from a(n Android) phone as it is being recorded

查看:160
本文介绍了如何上传从(N的Andr​​oid)手机的视频,因为它是被记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着写,因为他们正在通过.MP4文件中读取并且当它们被写入文件上传字节记录从Android手机上传视频的应用程序。问题是,据我所知道的,MOOV原子和其他一些杂七杂八的数据似乎并没有被写入文件,直到录像已完成,视频文件已经关闭。有什么办法来处理视频文件,并在服务器端添加这些元数据假设为

I'm trying to write an app that uploads videos from Android phones as they are being recorded by reading from .mp4 file and uploading the bytes as they are written to the file. The problem is that, as far as I can tell, the moov atom and some other assorted data do not seem to be written to file until the video recording has finished and the video file has been closed. Is there any way to process the video file and add these metadata on the server-side assuming either


  1. 完整的视频文件已经上传(但没有MOOV原子或没有得到在第一次写入的任何其他数据)

  2. 只有部分视频被上传(例如前10秒),我想这个转换成包含视频的上传段有效的MP4文件。

我见过像<一个链接href=\"http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system\" rel=\"nofollow\">http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system但他们粉饰问题,通过简单的声明

I've seen links like http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system but they gloss over the problem by simply stating

于是所接收的流将必须固定起来完成记录之后,或者原始视频/音频帧必须由服务器进行处理。

So the received stream will have to be fixed up after the recording is finished, or the raw video / audio frames have to be processed by the server.

没有确切解释如何去这样做。

without explaining exactly how to go about doing that.

推荐答案

当你已经注意到,MP4格式可能很难在这样的情况下使用。我怀疑链接博客文章不细讲关于固定起来,因为它可以是相当复杂。除了写MDAT盒的缺失大小字段,你需要生成ftyp和MOOV盒。如果你真的需要一个终端到终端的解决方案,MP4, ISO 14496 -12 ISO 14496-14 会告诉你,比你曾经想知道如何建立这些数据结构。

As you've noticed, the MP4 format can be difficult to use in such situations. I suspect the linked blog post doesn't go into detail about the "fixing up" because it can be quite involved. In addition to writing the missing size field of the mdat box, you'll need to generate the ftyp and moov boxes. If you really need an end-to-end MP4 solution, ISO 14496-12 and ISO 14496-14 will tell you more than you ever wanted to know about how to build these data structures.

不过,您可能会发现一个更优雅的解决方案是使用实际上是适用于实时处理的格式。换句话说,在Android侧,REMUX视频流为一个实时格式和发送到服务器。在服务器端,你就必须为处理视频极大的灵活性:可以REMUX整个视频回MP4,可以切片和切块,使10秒块,或什么的。开源项目Sipdroid <一个href=\"http://$c$c.google.com/p/sipdroid/source/browse/trunk/src/org/sipdroid/sipua/ui/VideoCamera.java\"相对=nofollow>包含了演示remuxing视频直播到RTP一些code 。 (您可能preFER一个可靠的传输格式 - RTP通过TCP,或任何 - 原理是一样的)

However, you might find that a much more elegant solution is to use a format that is actually suited for real-time processing. In other words, on the Android side, remux the video stream into a real-time format and send that to the server. On the server side, you then have great flexibility for processing the video: You can remux the whole video back into MP4, you can slice-and-dice, make 10-second chunks, or whatever. The open-source Sipdroid project contains some code that demonstrates remuxing live video into RTP. (You may prefer a reliable transmission format -- RTP over TCP, or whatever -- the principle is the same.)

这篇关于如何上传从(N的Andr​​oid)手机的视频,因为它是被记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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