简体   繁体   中英

AVAssetWriter: how to write to a single file multiple times

I am able to record video and save it in documents directory using AVFondation, now i want to re-open that saved video file and start recording again from the end of that file, is that possible or do i have to create multiple video files and merge them, please advise!

Regards,

I'm pretty sure there isn't a way to get the AVAssetWriter mux to append to an existing file. And of course if you need to prepend all the existing data when starting a new file, you will be slow to start.

An alternative is to start a new temporary file, and copy the data in the background into a third file, using something similar to http://www.gdcl.co.uk/2013/02/20/iOS-Video-Encoding.html . That is, you have file 1, which was closed when you suspended. You start writing to file 2 when you resume, and simultaneously read from 1 and write to a new file 3. when you've exhausted 1, you can read from file 2 (using the example code linked to above) and append that to file 3.

G

我想你应该阅读保存的视频,然后以NSData格式附加录制的视频,并重新重写整个数据..你可以使用NSMutableData来追加数据..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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