iphone - OSStatus error - 12780 when invoking insertTimeRange:ofTrack:atTime:error: of AVMutableCompositionTrack for the second time -


first of have love forum, helped me many time. have problem , couldn't find answer anywhere first question here.

my problem this:

i have video represented avplayeritem, user can edit video start time using cutbefore button cuts video left of slider

the method responsible cutting video following:

- (void)cutbeforeaction {   avmutablecomposition *composition = [avmutablecomposition composition];  // audio , video tracks of video avmutablecompositiontrack *compositionvideotrack = [composition addmutabletrackwithmediatype:avmediatypevideo preferredtrackid:kcmpersistenttrackid_invalid]; avmutablecompositiontrack *compositionaudiotrack = [composition addmutabletrackwithmediatype:avmediatypeaudio preferredtrackid:kcmpersistenttrackid_invalid];  // calculate new duration cmtime currstarttime = _player.currentitem.currenttime; cmtime endtime = _player.currentitem.duration; cmtimerange range = cmtimerangefromtimetotime(currstarttime, endtime);  // insert new duration tracks nserror *error = nil; [compositionvideotrack inserttimerange:range                                 oftrack:[[_player.currentitem.asset trackswithmediatype:avmediatypevideo] objectatindex:0]                                 attime:kcmtimezero                                  error:&error];  [compositionaudiotrack inserttimerange:range                                 oftrack:[[_player.currentitem.asset trackswithmediatype:avmediatypeaudio] objectatindex:0]                                 attime:kcmtimezero                                  error:&error]; // create new avplayeritem new composition avplayeritem *item = [avplayeritem playeritemwithasset:composition]; [self setplayeritem:item]; [_player replacecurrentitemwithplayeritem:item];  // change player location beginning of video [_player seektotime:cmtimemakewithseconds(0, 1)]; [self synctimelabel]; [self syncscrubber]; 

}

when running - (void)cutbefore method firs time works fine, when run second time (the video has been edited once) the

[compositionvideotrack inserttimerange:range                             oftrack:[[_player.currentitem.asset trackswithmediatype:avmediatypevideo] objectatindex:0]                             attime:kcmtimezero                              error:&error]; 

and

[compositionaudiotrack inserttimerange:range                             oftrack:[[_player.currentitem.asset trackswithmediatype:avmediatypeaudio] objectatindex:0]                             attime:kcmtimezero                              error:&error]; 

methods returns following error:

the operation couldn’t completed. (osstatus error -12780.)

i tried error code means found practically nothing.

thanks help

i found workaround issue, seems using method inserttimerange:oftrack:attime:error: avmutablecomposition's track input track causing error, did saving initial asset (which wasn't instance of avmutablecomposition instance of avasset), , using track input inserttimerange:oftrack:attime:error:


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -