I have a demand: get the frame image before play video streaming(m3u8) , as a video preview display. I use AVPlayerItemVideoOutpu copyPixelBufferForItemTime: itemTimeForDisplay: only when play the video streaming to get to the frame image , do you have other method? thanks!!
This is my code :
CMTime itemTime = self.playerItem.currentTime;
CVPixelBufferRef pixelBuffer = [_playerItemVideoOutput copyPixelBufferForItemTime:itemTime itemTimeForDisplay:nil];
CIImage *ciImage = [CIImage imageWithCVPixelBuffer:pixelBuffer];
CIContext *temporaryContext = [CIContext contextWithOptions:nil];
CGImageRef videoImage = [temporaryContext
createCGImage:ciImage
fromRect:CGRectMake(0, 0,
CVPixelBufferGetWidth(pixelBuffer),
CVPixelBufferGetHeight(pixelBuffer))];
UIImage *uiImage = [UIImage imageWithCGImage:videoImage];
CGImageRelease(videoImage);
NSLog(@"uiImage:%@", uiImage);