ios - Filtering video with GPUImage -


i'm using gpuimage in application , trying filter video. live video filtering working well. trouble comes when try read video memory filesystem , apply filters using code posted on sunsetlakessoftware tutorial page , in simplevideofilefilter demo.

edit: realized original post may not have been posing specific enough question. asking is: how can read video disk memory, apply gpuimagefilter, , overwrite original filtered version?

the application crashing following error:

-[avassetwriter startwriting] cannot call method when status 2

status 2 avassetwriterstatuscompleted. i've seen same failure occur 3 other avassetwriterstatuses.

i have posted relevant code below.

gpuimagefilter *selectedfilter = [self.allfilters objectatindex:indexpath.item];  // file url stored when video captured nsurl *url = [self.videourlsbyindexpath objectforkey:self.indexpathfordisplayedimage];  gpuimagemovie *moviefile = [[gpuimagemovie alloc] initwithurl:url]; moviefile.runbenchmark = yes; moviefile.playatactualspeed = no; [moviefile addtarget:selectedfilter]; // apply user-selected filter file  unlink([url.absolutestring utf8string]); // delete file @ file url it's writeable  // different movie writer 1 using live video capture. gpuimagemoviewriter *editingmoviewriter = [[gpuimagemoviewriter alloc] initwithmovieurl:url size:cgsizemake(640.0, 640.0)];  [selectedfilter addtarget:editingmoviewriter];  editingmoviewriter.shouldpassthroughaudio = yes; moviefile.audioencodingtarget = editingmoviewriter; [moviefile enablesynchronizedencodingusingmoviewriter:editingmoviewriter];  [editingmoviewriter startrecording]; [moviefile startprocessing]; // commenting out line prevents crash  // weak variables prevent retain cycle __weak gpuimagemoviewriter *weakwriter = editingmoviewriter; __weak id weakself = self; [editingmoviewriter setcompletionblock:^{     [selectedfilter removetarget:weakwriter];     [weakwriter finishrecording];     [weakself savephotostolibrary]; // use alassetslibrary write camera roll }]; 

perhaps issue scope of editingmoviewriter. or perhaps fact initializing gpuimagemovie instance same url attempting write to. have read several posts on issues page of gpuimage github, several related posts on so, readme, , tutorial linked above.

any insight issue appreciated. thanks.

there's @ least 1 thing here might behind this. in code above, you're not hanging on strong reference moviefile source object.

if arc-enabled project, object deallocated instant complete setup method (if it's not, you'll leaking object). stop movie playback, deallocate movie itself, , lead black frames being sent down filter pipeline (other potential instabilities).

you need make moviefile strongly-referenced instance variable make sure hangs on past setup method, since movie processing asynchronous.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -