We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(void)videoCaptureOutputDataCallback:(CMSampleBufferRef)sampleBuffer { if(captureYuvFrame) { CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferLockBaseAddress(imageBuffer, 0); const uint8_t* dataY = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 0);//YYYYYYYY size_t strideY = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 0); const uint8_t* dataUV = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 1);//UVUVUVUV size_t strideUV = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 1); size_t width = CVPixelBufferGetWidth(imageBuffer); size_t height = CVPixelBufferGetHeight(imageBuffer);
// todo render nv12 CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
} else { // CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferLockBaseAddress(imageBuffer, 0); auto width = CVPixelBufferGetWidth(imageBuffer); auto height = CVPixelBufferGetHeight(imageBuffer); auto stride = CVPixelBufferGetBytesPerRow(imageBuffer)/4; auto pixels = (const uint8_t )CVPixelBufferGetBaseAddress(imageBuffer); gpuPixelRawInput->uploadBytes(pixels, width, height, stride); CVPixelBufferUnlockBaseAddress(imageBuffer, 0); } } 按我的理解captureYuvFrame == YES时,应该也有类似 gpuPixelRawInput->uploadBytes(pixels, width, height, stride); 这样的数据输入逻辑,我这边自己设置 CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferLockBaseAddress(imageBuffer, 0); const uint8_t dataY = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 0);//YYYYYYYY size_t strideY = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 0); const uint8_t* dataU = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 1);//UVUVUVUV size_t strideU = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 1); const uint8_t* dataV = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 2);//UVUVUVUV size_t strideV = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 2); size_t width = CVPixelBufferGetWidth(imageBuffer); size_t height = CVPixelBufferGetHeight(imageBuffer); gpuPixelRawInput->uploadBytes(width, height, dataY, strideY, dataU, strideU, dataV, strideV); CVPixelBufferUnlockBaseAddress(imageBuffer, 0); 得到的结果视频效果是花屏效果,麻烦请补充一下YUV格式的demo示例代码
The text was updated successfully, but these errors were encountered:
No branches or pull requests
(void)videoCaptureOutputDataCallback:(CMSampleBufferRef)sampleBuffer {
if(captureYuvFrame) {
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer, 0);
const uint8_t* dataY = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 0);//YYYYYYYY
size_t strideY = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 0);
const uint8_t* dataUV = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 1);//UVUVUVUV
size_t strideUV = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 1);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
} else {
//
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer, 0);
auto width = CVPixelBufferGetWidth(imageBuffer);
auto height = CVPixelBufferGetHeight(imageBuffer);
auto stride = CVPixelBufferGetBytesPerRow(imageBuffer)/4;
auto pixels = (const uint8_t )CVPixelBufferGetBaseAddress(imageBuffer);
gpuPixelRawInput->uploadBytes(pixels, width, height, stride);
CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
}
}
按我的理解captureYuvFrame == YES时,应该也有类似 gpuPixelRawInput->uploadBytes(pixels, width, height, stride);
这样的数据输入逻辑,我这边自己设置
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer, 0);
const uint8_t dataY = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 0);//YYYYYYYY
size_t strideY = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 0);
const uint8_t* dataU = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 1);//UVUVUVUV
size_t strideU = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 1);
const uint8_t* dataV = (const uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, 2);//UVUVUVUV
size_t strideV = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, 2);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
gpuPixelRawInput->uploadBytes(width, height, dataY, strideY, dataU, strideU, dataV, strideV);
CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
得到的结果视频效果是花屏效果,麻烦请补充一下YUV格式的demo示例代码
The text was updated successfully, but these errors were encountered: