在仍使用AVFoundation录制的同时可以进行视频文件“分块"/分段吗? [英] Is it possible to do video file "chunking"/segmenting while still recording using AVFoundation?

查看:96
本文介绍了在仍使用AVFoundation录制的同时可以进行视频文件“分块"/分段吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用AVFoundation在OS X上录制视频,但是它一直等到录制结束才保存文件.我希望能够保存每5/10/X秒捕获的内容.

I am attempting to use AVFoundation to record video on OS X but it waits till then end of the recording to save the file. I want to be able to have it save whatever it has captured every 5/10/X seconds.

我需要这样做,以便在保存视频文件时可以将片段流传输到服务器,同时仍在录制视频,这样我就可以将几乎实时"的视频从服务器中存储起来.

I need to do this so that as it saves off the video files I can stream the segments to a server while the video is still recording so I can server up "almost live" video off the server.

感谢您可能提供的帮助!

Thanks for any help you may be able to provide!

推荐答案

您可以要求AVFoundation在录制时将帧出售给您,然后只需将一定数量的帧传递给服务器即可.但是,您要问的事情变得非常复杂,因为带宽或临时网络故障可能会导致延迟/跳过等.

You can ask AVFoundation to vend the frames to you as it is recording, then just pass a set number of frames to the server. But what you are asking about is extremely complicated to get right, since bandwidth or temporary network blips can cause delays/skips, etc.

我们在此处讨论了有关通过使用AVCaptureSession和AVCaptureVideoDataOutput来出售MPEG帧的确切方法: 在iPhone上上传实时视频附近

We had a discussion about doing this exact thing over here, by using AVCaptureSession with AVCaptureVideoDataOutput to vend the MPEG frames: Near Real Time Video Upload from iPhone

如果您希望单个块可播放,则必须将它们包装在MOV或MPEG容器中,但这听起来并不像您的方案中所需要的那样.

If you want the individual chunks to be playable, you'll have to wrap them in a MOV or MPEG container, but it doesn't sound like you need that in your scenario.

这篇关于在仍使用AVFoundation录制的同时可以进行视频文件“分块"/分段吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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