Skip to content
New issue

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

[Feature Request]实时视频想捕获图像或者录制视频,怎么实现呢。尝试用captureAProcessedFrameData捕获图像,崩溃报错“EXC_BAD_ACCESS” #109

Open
celiaDeveloper opened this issue Nov 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@celiaDeveloper
Copy link

看之前的分享,尝试用下面的方法获取图片加完滤镜后的结果,是可以获取到UIImage的
` gpuSourceImage->Render();
unsigned char* res = gpuSourceImage->captureAProcessedFrameData(beauty_face_filter_);
int imageWidth = gpuSourceImage->getRotatedFramebufferWidth();
int imageHeight = gpuSourceImage->getRotatedFramebufferHeight();

// make data provider with data.
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, res, imageWidthimageHeight4, NULL);

// prep the ingredients
int bitsPerComponent = 8;
int bitsPerPixel = 32;
int bytesPerRow = 4 * imageWidth;
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;

// make the cgimage
CGImageRef imageRef = CGImageCreate(imageWidth, imageHeight, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);

// then make the uiimage from that
UIImage *image = [UIImage imageWithCGImage:imageRef];`

基于上面的思路,对实时视频实现捕获图像,SourceRawDataInput也可以调用captureAProcessedFrameData这个方法,于是用下面的方法尝试捕获图像,但是直接崩溃在第一行,崩溃信息是“Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)”
` unsigned char* res = gpuPixelRawInput->captureAProcessedFrameData(beauty_face_filter_);
int imageWidth = gpuPixelRawInput->getRotatedFramebufferWidth();
int imageHeight = gpuPixelRawInput->getRotatedFramebufferHeight();

// make data provider with data.
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, res, imageWidthimageHeight4, NULL);

// prep the ingredients
int bitsPerComponent = 8;
int bitsPerPixel = 32;
int bytesPerRow = 4 * imageWidth;
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;

// make the cgimage
CGImageRef imageRef = CGImageCreate(imageWidth, imageHeight, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);

// then make the uiimage from that
UIImage *image = [UIImage imageWithCGImage:imageRef];`

友友们,怎么实现捕获图像和录制视频呢

@celiaDeveloper celiaDeveloper added the enhancement New feature or request label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant