Guig
Guig

Reputation: 10197

AVPlayerItemVideoOutput.copyPixelBuffer fails with EXC_BAD_ACCESS

I've that function:

func retrievePixelBufferToDraw() -> CVPixelBuffer? {
  let time = self.playerItem!.currentTime()

  // this line is just added to make sure I can call something on self.videoOutput!
  self.videoOutput!.hasNewPixelBuffer(forItemTime: time)

  // raises EXC_BAD_ACCESS
  let pixelBuffer = self.videoOutput!.copyPixelBuffer(forItemTime: time, itemTimeForDisplay: nil)
  return pixelBuffer
}

It sounds like EXC_BAD_ACCESS comes from accessing deallocated variables, but I don't really see how that'd come into play here since I've checked all the variables I'm using before calling the line that fails.

Upvotes: 0

Views: 646

Answers (1)

JAck
JAck

Reputation: 854

Simple.. Your AVPlayer is not getting video input at same time it is throwing the error EXC_BAD_ACCESS Try to give it QuickTimeMovie when you are playing (player.play()) always require video input.

At the end player should not be nill(without proper playerItem)

Upvotes: 1

Related Questions