0

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)?

peetonn
  • 2,942
  • 4
  • 32
  • 49
  • The rendering corruption makes me suspect this is an OS-level issue, possibly involving hardware video decoding. Does the issue occur on other computers? If so, have you [filed a bug with Apple](https://bugreporter.apple.com/)? –  Oct 25 '16 at 23:39
  • Could there be memory issues? You can't keep that many frames in memory at once. Do the errors persist if you discard the frames? – Rhythmic Fistman Jan 20 '17 at 22:30
  • Rhythmic is most likely correct, are you just holding all the decoded frames in memory until the process runs out of memory? Here is a link to a blog post that describes video memory usage: https://stackoverflow.com/a/17224921/763355 – MoDJ Sep 17 '18 at 17:08

0 Answers0