Skip to content

Instantly share code, notes, and snippets.

@aminbenarieb
Created March 20, 2020 17:19
Show Gist options
  • Save aminbenarieb/be8cacb68d8c341ecd8dc0f677af06a9 to your computer and use it in GitHub Desktop.
Save aminbenarieb/be8cacb68d8c341ecd8dc0f677af06a9 to your computer and use it in GitHub Desktop.
let framesPerSecond = min(self.nominalFrameRate, self.framesPerSecond)
let processedFrameIdx = Int64(self.nominalFrameRate / framesPerSecond)
guard self.frameCounter.value % processedFrameIdx == 0 else {
sample = self.assetReader?.outputs.first?.copyNextSampleBuffer()
continue
}
usleep(UInt32(1000 * Int(1000.0 * 1.0 / framesPerSecond) * self.framesRate))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment