swift - Most performant method of processing video and writing to file - ios AVFoundation -
i want read in video asset on disk , bunch of processing on it, things using cicropfilter
on each individual frame , cutting out mask, splitting 1 video several smaller videos, , removing frames original track "compress" down , make more gif-like.
i've come few possible avenues:
avassetwriter
,avassetreader
in scenario, read in cmsamplebuffer
s file, perform desired manipulations, write new file using avassetwriter
.
avmutablecomposition
here, given list of cmtimes
can cut out frames , rewrite video or create multiple compositions each new video want create, export of them using avassetexportsession
.
the metrics i'm concerned about: performance , power. i'm interested in method offers greatest efficiency in performing edits while giving me flexibility want. i'd imagine kind of video editing i'm describing can done both approaches want performant/with best capabilities.
in experience avassetexportsession more performant using avassetreader , avassetwriter straight forward format -> format b type conversion, said, it's not enough concerned about.
according apple's own documentation https://developer.apple.com/library/ios/documentation/audiovideo/conceptual/avfoundationpg/articles/00_introduction.html#//apple_ref/doc/uid/tp40010188:
you use export session reencode existing asset format defined 1 of small number of commonly-used presets. if need more control on transformation, in ios 4.1 , later can use asset reader , asset writer object in tandem convert asset 1 representation another. using these objects can, example, choose of tracks want represented in output file, specify own output format, or modify asset during conversion process.
given nature of question, seems don't have experience avfoundation framework yet. advice start avassetexportsession , when hit road block, move deeper down stack avassetreader , avassetwriter.
eventually, depending on how far take this, may want write own custom compositor.
Comments
Post a Comment