繁体   English   中英

FFMPEG帧到DirectX表面

[英]FFMPEG Frame to DirectX Surface

从FFMPEG的avcodec_decode_video ()函数获得指向AVFrame的指针,如何将图像复制到DirectX表面? (假设我有一个指向适当大小的DX X8R8G8B8表面的指针。)

谢谢。

约翰。

您可以使用FFMPEG的img_convert()函数将图像同时复制到您的表面并将其转换为RGB格式。 这是我最近的一个项目中粘贴的几行代码,做了类似的事情(尽管我使用的是SDL而不是DirectX):

    AVFrame *frame;
    avcodec_decode_video(_ffcontext, frame, etc...);

    lockYourSurface();
    uint8_t *buf = getPointerToYourSurfacePixels();

// Create an AVPicture structure which contains a pointer to the RGB surface.
    AVPicture pict;

    memset(&pict, 0, sizeof(pict));

    avpicture_fill(&pict, buf, PIX_FMT_RGB32,
                   _ffcontext->width, _ffcontext->height);



// Convert the image into RGB and copy to the surface.
    img_convert(&pict, PIX_FMT_RGB32, (AVPicture *)frame,
                _context->pix_fmt, _context->width, _context->height);


    unlockYourSurface();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM