问题
I need to read all frames from three short video files (3min each) into the memory (NSArray
of CMSampleBufferRef
).
I used typical approach with AVAsset
, AVAssetReader
, AVAssetReaderTrackOutput
and calling copyNextSampleBuffer
in while
loop.
It works okay for 1 file - all 3570 samples are loaded. If I try to load two more files (sequentially) - second loads only 1820 samples, third loads 0 with error -1189 (Cannot Open). And I tried both main thread, background thread and designated thread (dispatch_queue_t
concurrent or serial - same effect).
If I try to load all three simultaneously (each has its own dispatch_queue_t
) - all three load around 1800 samples without any errors (which is not the full length of the videos).
As a weird side effect after I run my app in Xcode - I get windows (and webpages) rendering glitches throughout the system (in Chrome, Finder, when dragging windows).
What would be the right approach to load all video samples into the array from several videos in background to not to lock UI (simultaneously or sequentially)?
来源:https://stackoverflow.com/questions/40251042/reading-multiple-video-files-using-avassetreadertrackoutput-simultaneously-fre