iOS/AVFoundation: How to eliminate (occasional) blank frames between different videos within an AVComposition during playback -
the app i’m working on loops video specified # of times adding same avassettrack (created original video url) multiple times same avcomposition @ successive intervals. app inserts new video clip existing composition 'removing' time range composition's avmutablecompositiontrack (for avmediatypevideo) , inserting new clip's avassettrack removed time range.
however, , rarely, after inserting new clip described above time range within repeat of original looping video, there resulting blank frames appear @ video loop’s transition points (within composition), during playback - video exports correctly without gaps.
this leads me believe issue avplayer or avplayeritem , how frames buffered playback, rather how i'm inserting/ looping clips or choosing correct cmtime stamps so. app doing bunch of things @ once (loop visualization in ui via nstimer, audio playback via amazing audio engine) - issue result of competition resources?
one more note: understand discrepancies between audio , video in asset can cause glitches (i.e. underlying audio little bit longer video length), i'm not adding audioencodingtarget gpuimagewriter i'm using record , save video, videos have no audio components.
any thoughts or directions can point me in appreciated! many in advance.
update: flashes coincide "had drop video frame" error logged gpuimage library, according creator has phone not being able process video fast enough. can multi-threading solving this?
update 2: flashes don't always correspond had drop video frame error. have disabled of avrecorder/amazing audio engine code , issue still persists making not problem of resource competition between engines. have been logging properties of avplayer item , notice 'isplaybacklikelytokeepup' no, , 'isplaybackbufferfull' yes.
so problem solved - sort of frustrating how brutally simple fix is. used time range frame shorter adding videos composition rather avassettrack's time range. no more flashes. users won't miss 30th of second :)
shortened_duration = cmtimesubtract(originalvideoassettrack.timerange.duration, cmtimemake(1,30));
Comments
Post a Comment