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

YUV格式的视频数据,demo麻烦可以补充完整吗 #101

Open
shucheng7zhong opened this issue Sep 18, 2024 · 0 comments
Open

YUV格式的视频数据,demo麻烦可以补充完整吗 #101

shucheng7zhong opened this issue Sep 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@shucheng7zhong
Copy link

shucheng7zhong commented Sep 18, 2024

  • (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示例代码

@shucheng7zhong shucheng7zhong added the bug Something isn't working label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant