FFMPEG帧到DirectX表面 [英] FFMPEG Frame to DirectX Surface

查看:1007
本文介绍了FFMPEG帧到DirectX表面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Given a pointer to an AVFrame from FFMPEG's avcodec_decode_video() function how do I copy the image to a DirectX surface? (Assume I have a pointer to an appropriately sized DX X8R8G8B8 surface.)

谢谢。

John。 / p>

John.

推荐答案

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

You can use FFMPEG's img_convert() function to simultaneously copy the image to your surface and convert it to RGB format. Here's a few lines of code pasted from a recent project of mine which did a similar thing (although I was using SDL instead of 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();

这篇关于FFMPEG帧到DirectX表面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆