Thursday, 15 April 2010

ios6 - iOS: get video duration and thumbnails without playing video -



ios6 - iOS: get video duration and thumbnails without playing video -

i need (local) video's duration, , access individual frames uiimages. far i've been using mpmovieplayercontroller this.

first register mpmoviedurationavailablenotification events, , phone call preparetoplay. when event received note video's duration, , request frames via requestthumbnailimagesattimes.

this works, video seems start playing if have not added view in way (i can hear sound playing in background).

is there way video's duration , frames without playing video?

to duration:

nsurl *sourcemovieurl = [nsurl fileurlwithpath:somepath]; avurlasset *sourceasset = [avurlasset urlassetwithurl:sourcemovieurl options:nil]; cmtime duration = sourceasset.duration;

to framegrab:

avassetimagegenerator* generator = [avassetimagegenerator assetimagegeneratorwithasset:destinationasset]; //get 1st frame 3 seconds in int frametimestart = 3; int framelocation = 1; //snatch frame cgimageref frameref = [generator copycgimageattime:cmtimemake(frametimestart,framelocation) actualtime:nil error:nil];

ios ios6

No comments:

Post a Comment