i'm trying trim , download online video using avexportsession.
code:
filemove *filemove = (filemove*)data; nsstring *url = @"http://download.wavetlan.com/svv/media/http/h264/talkinghead_media/h264_test1_talkinghead_mp4_480x360.mp4"; nsurl *videourl = [nsurl urlwithstring:[url stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]]; nslog(@"videourl: %@",videourl); avasset *anasset = [avurlasset urlassetwithurl:videourl options:nil]; nsarray *compatiblepresets = [avassetexportsession exportpresetscompatiblewithasset:anasset]; if ([compatiblepresets containsobject:avassetexportpresetlowquality]) { avassetexportsession *exportsession = [[avassetexportsession alloc] initwithasset:anasset presetname:avassetexportpresetlowquality]; nsurl *outputurl = [nsurl fileurlwithpath:filemove.dst]; nslog(@"outputurl: %@",outputurl); exportsession.outputurl = outputurl; exportsession.outputfiletype = avfiletypequicktimemovie; cmtime start = cmtimemakewithseconds(1.0, 600); cmtime duration = cmtimemakewithseconds(3.0, 600); cmtimerange range = cmtimerangemake(start, duration); exportsession.timerange = range; if ([[nsfilemanager defaultmanager] fileexistsatpath:filemove.dst]) [[nsfilemanager defaultmanager] removeitematpath:filemove.dst error:nil]; [exportsession exportasynchronouslywithcompletionhandler:^{ switch ([exportsession status]) { case avassetexportsessionstatusfailed: nslog(@"export failed: %@", [[exportsession error]description ]); break; case avassetexportsessionstatuscancelled: nslog(@"export canceled"); break; default: break; } }]; } error:
export failed: error domain=avfoundationerrordomain code=-11800 "the operation not completed" userinfo=0x635a820 {nslocalizeddescription=the operation not completed, nsunderlyingerror=0x1ff4240 "the operation couldn’t completed. (osstatus error -12780.)", nslocalizedfailurereason=an unknown error occurred (-12780)}
do guys see issue in code ? there limitation in avexportsession accessing online video ?
the url used creating avasset needs local file have access to. need download onto device before creating avasset like so
Comments
Post a Comment