ios - Unknown exception when exporting video asset -


i have following code export video data photos:

if (asset.mediatype == phassetmediatypevideo) {     [[phimagemanager defaultmanager] requestavassetforvideo:asset options:nil resulthandler:^(avasset *asset, avaudiomix *audiomix, nsdictionary *info) {         avassetexportsession *exportsession = [[avassetexportsession alloc] initwithasset:asset presetname:avassetexportpresetpassthrough];         exportsession.outputfiletype = avfiletypequicktimemovie;         [exportsession exportasynchronouslywithcompletionhandler:^{             [[sharedmanager sharedinstance] insertattachment:exportsession.outputurl forevent:event];         }];     }]; } 

this code rises unidentified exception (with breakpoints disabled) on line [exportsession export...] thing. exportsession valid, shows outputfiletype = (null) in log, had set manually.

i can see url of video, file://private.mobile....mov, captured camera , stored in assets catalog (i can watch photos). has 2 seconds length.

please, me out. how export video file using photos?

p.s.: exporting of images using phimagemanager works fine.

okay, i've found issue. not said in documentation, required outputurl set manually. following peace of code (from answer https://stackoverflow.com/a/20244790/773451) required:

nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *outputurl = paths[0]; nsfilemanager *manager = [nsfilemanager defaultmanager]; [manager createdirectoryatpath:outputurl withintermediatedirectories:yes attributes:nil error:nil]; outputurl = [outputurl stringbyappendingpathcomponent:@"output.mov"]; // remove existing file [manager removeitematpath:outputurl error:nil]; exportsession.outputurl = [nsurl fileurlwithpath:outputurl]; 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -