Render video in metal.

So I wanted to render video from .mov file in MTKView.

Short algorithm:

  1. Read CMSampleBuffer from .mov using AVAssetReader and AVAssetReaderTrackOutput.

  2. Convert CMSampleBuffer from step 1 to MTLTexture and pass it to renderer

I did those 2 steps and got the picture with twitches and I don’t know why.

Link to .mov https://www.dropbox.com/s/gmzxd8j94pjhc1q/2.MOV?dl=0.

Link to result https://www.dropbox.com/s/exgf1tk7oqvon25/result.mov?dl=0.

The code.