无法在 SDL_Surface 上显示 YUV 叠加 [英] Cannot display YUV Overlay on SDL_Surface
问题描述
我想通过隐藏其 SDL 视频播放器窗口来修改 ffplay
.相反,我想将叠加层作为逐个像素的位图抓取,以便在我的程序中的其他地方使用.
I want to modify ffplay
by hiding its SDL video player window. Rather, I want to grab the overlay as pixel-by-pixel bitmaps to be used elsewhere in my program.
现在ffplay
可以简化如下:
从
SDL_SetVideoMode()
从SDL_CreateYUVOverlay()
创建SDL_Overlay *bmp
并将其与screen
重复直到视频结束
解码电影帧并填充 bmp
Decode movie frames and populate bmp
使用 SDL_DisplayYUVOverlay()
根据这篇文章的提示,我已将第 1 步替换为如下所示:
Following hints from this article, I have replaced Step 1 as below:
/* Don't want video player window showing on screen
* int flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
* screen = SDL_SetVideoMode(w, h, 24, flags);
*/
Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x00000000;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0x00000000;
#endif
screen = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 24, rmask, gmask, bmask, amask);
和步骤 4 为
SDL_DisplayYUVOverlay(bmp, &rect);
SDL_SaveBMP(screen, filenameN); N++;
问题:如果我只修改第 4 步,位图文件将得到正确保存,这正是我想要的,除了视频播放窗口是可见的.另一方面,如果我也修改步骤 2,则窗口成功隐藏,位图全部变黑.
Issue: If I modify only Step 4, the bitmap files are getting saved properly which is what I want, except that the video playing window is visible. On the other hand, if I modify Step 2 as well, the window gets successfully hidden the bitmaps are all blacked out.
我是 SDL 的新手,所以除了解决方案之外,解释为什么我的方法不起作用会很有帮助.
I am new to SDL, so apart from just the solution, an explanation on why my approach does not work will be helpful.
推荐答案
使用 SDL_putenv("SDL_VIDEODRIVER=dummy");
使用 虚拟 视频驱动程序,不产生输出.
Use SDL_putenv("SDL_VIDEODRIVER=dummy");
to use the dummy video driver, which produces no output.
这篇关于无法在 SDL_Surface 上显示 YUV 叠加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!