Reading multiple video files using “AVAssetReaderTrackOutput” simultaneously freaks out OSX

我的未来我决定 提交于 2019-12-13 05:43:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!