简体   繁体   English

avassetwriter是否有可能输出到内存

[英]is it possible for avassetwriter to output to memory

I would like to write an iphone app that continuously capture video, h.264 encode them in 10 seconds interval and upload to a storage server. 我想编写一个iphone应用程序,该应用程序可以连续捕获视频,以10秒的间隔对h.264进行编码,然后上传到存储服务器。 This can be done with avassetwriter, and I can keep on deleting the old files as I create new ones. 这可以通过avassetwriter完成,在创建新文件时,我可以继续删除旧文件。 However, as flash memory have a limited write cycles, this scheme will destroy the flash after a few thousand write cycles through the flash. 但是,由于闪存的写入周期有限,因此该方案将在通过闪存数千次写入周期后破坏闪存。 Is there a way to redirect avassetwriter to memory, or create a ram drive on the iphone? 有没有一种方法可以将avassetwriter重定向到内存,或在iPhone上创建RAM驱动器?

Thanks! 谢谢!

Yes avassetwriter is the only way to get to the hardware decoder. 是的,avassetwriter是访问硬件解码器的唯一方法。 and simply reading back the file while its written doesn't give you the moov atoms so avfoundation or mpmediaplayer based players won't be able to read it back. 并在文件写入时简单地读回该文件并不会给您带来麻烦,因此基于avfoundation或mpmediaplayer的播放器将无法将其读回。 you only have a couple choices , periodically stop the asassetwriter and write to the file on a background thread, effectively segmenting your movie into smaller complete files. 您只有几个选择,可以定期停止asassetwriter,并在后台线程上写入文件,从而有效地将电影分割成较小的完整文件。 or you could deal with the incomplete mp4 on the server side, you will have to decode the raw nalu's and recreate the missing moov atoms. 或者您可以在服务器端处理不完整的mp4,则必须解码原始nalu并重新创建丢失的moov原子。 If your using ffmpeg mov.c is source to look at. 如果您使用ffmpeg mov.c是要查看的源。 This is also were an incomplete mp4 file would fail. 这也是不完整的mp4文件会失败的原因。

Why write the data to a file at all? 为什么要将数据全部写入文件? Couldn't you just copy the capture data in memory and then push it to the server from memory? 您不能只是将捕获的数据复制到内存中,然后将其从内存中推送到服务器吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM