来自iPhone的近实时视频上传 [英] Near Real Time Video Upload from iPhone

查看:119
本文介绍了来自iPhone的近实时视频上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试尽可能快地找到从iPhone(iOS5)上传视频的最佳方式 - 如果可能,请实时。

I am trying to find the best way to upload video from an iPhone (iOS5) as fast as possible - real time if possible.

我发现此前一个问题并且回答非常有用。

从iPhone流式传输视频

I found this previous question and answer very useful.
streaming video FROM an iPhone

但它给我留下了几个悬而未决的问题。我没有足够的代表在这个问题上发表评论 - 我认为我的问题无论如何都超出了原始问题的范围。

But it has left me with several unanswered questions. I dont have enough rep to post comments in that question- and I think my questions are getting beyond the scope of the original question anyway.

所以:


  1. 正在使用AVCaptureSession / AVAssetWriter并将视频切成短片,这是从iPhone快速移动(压缩)视频的最佳方式 - 近乎实时?

  1. Is using AVCaptureSession/AVAssetWriter and chopping the video into short clips the best way to rapidly move (compressed) video off of the iPhone - in near realtime?

如果是这样,有人可以提供有关如何使用两个AVAssetWriters和后台队列的更多详细信息以避免丢失(正如用户Steve McFarlin在上面引用的问题中提到的那样) ?我不清楚从一个AVAssetWriter到另一个AVAssetWriter的切换是如何工作的......

If so could someone supply more details on how to use two AVAssetWriters and a background queue to avoid dropouts (as user Steve McFarlin mentions in the referenced question above)? I am unclear how the handoff from one AVAssetWriter to another would work...

(严重)是否有一种简单的方法可以将切碎的视频文件追加回一个完整的视频......或者至少能够播放它们就好像它们是一个完整的视频一样?我需要将较小的文件合并为服务器和iPhone上的一个文件(用于预览)。

(Critical) Is there an easy way to append the chopped video files back into a full length video... or at least be able to play them as if they were one complete video? I would need to merge the smaller files to look like one file both on the server AND on the iPhone (for preview).

感谢您的帮助...

推荐答案

您可以尝试在手机上进行缓冲,但这似乎是反击因为它的记忆力有限,对我来说很有成效。我会尝试设置一个AVCaptureSession并使用AVCaptureVideoDataOutput,它将在一个单独的dispatch_queue线程上向你提供帧(如果设置它会将它们作为MPEG帧出售)。该线程可以将帧移交给异步套接字以进行传输,可能使用指示帧编号和视频格式的小标头。或者,您可以通过队列将数据移交给发送线程,这样可以监视等待传输的帧数。

Well you can try to do the buffering on the phone but that seems counter-productive to me, given that it has limited memory. I would try setting up an AVCaptureSession and use the AVCaptureVideoDataOutput which will vend the frames to you on a separate dispatch_queue thread (if setup it will vend them as MPEG frames). That thread can hand the frames off to an async socket to transmit, possibly with a small header that indicates the frame number and video format. Alternately you can hand the data off to a sending thread via a queue which would let you monitor how many frames are waiting to be transmitted.

在接收服务器上,你' d想要处理创建一个小缓冲区(比如几秒钟),如果它们无序到达就进行帧重新排序。

On the receiving server, you'd want to deal with creating a small buffer (say a few seconds) and doing the frame reordering if they arrive out of order.

最大的问题是检测带宽并且知道何时降低质量,这样你就不会有积压的数据包等待出去。这是一个完全不同且复杂的主题:)如果编解码器,质量和视频大小......将直接决定实时传输帧所需的带宽,关键将在您的选择中。在某些模式下,AVVideoCodecH264在硬件中受支持,可能是实时编码的唯一现实选择。

The big issue will be detecting the bandwidth and knowing when to drop the quality down so you don't end up with a backlog of packets waiting to go out. That's an entirely different and complicated topic :) The key will be in your selection if codec, quality, and video size... that is going to directly determine the bandwidth required to transmit the frames in real-time. AVVideoCodecH264 is supported in hardware in certain modes and is probably the only realistic option for real-time encoding.

我认为你不会找到现成的这方面的例子,因为它代表了很多工作才能正常工作。

I don't think you are going to find a ready-made example for this though as it represents a lot of work to get working just right.

这篇关于来自iPhone的近实时视频上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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