allentsing / ATijkplayeriOS

1、编译ijkPlayer,支持RTSP拉流播放,支持http等格式。2、加入了MD360Player4iOS,实现视频的全景渲染。3、MovieRecorder用实时拉过来的音视频数据进行录视频。4、LFLiveKit用拉流过来的原始音视频数据(YUV、PCM)进行推流直播。
53 stars 10 forks source link

CVPixelBufferRef setting questions #4

Closed asata closed 7 years ago

asata commented 7 years ago

Hello I applied MD360Player4iOS in the latest version of IJKPlayer. I have successfully modified the IJKPlayer to return a CVPixelBufferRef to snapshot and save the video. But the color of the image is not coming out properly. The code below is the code used for the modification. Format Type : I420

Please let me know if there is any part to fix. please answer about my question.

NSDictionary *pixelAttributes = @{(id)kCVPixelBufferIOSurfacePropertiesKey : @{}};
CVPixelBufferRef pixelBuffer = NULL;
CVReturn result = CVPixelBufferCreate(kCFAllocatorDefault,
                                             overlay->w,
                                             overlay->h,
                                             kCVPixelFormatType_420YpCbCr8BiPlanarFullRange,
                                             (__bridge CFDictionaryRef)(pixelAttributes),
                                             &pixelBuffer);
CVPixelBufferLockBaseAddress(pixelBuffer, 0);

uint8_t *yDestPlane = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
memcpy(yDestPlane, frame->pixels[0], (frame->pitches[0] * frame->h));
uint8_t *uvDestPlane = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1);
memcpy(uvDestPlane, frame->pixels[1] , (frame->w * frame->h / 4));

CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
CVPixelBufferRelease(pixelBuffer);