Cannot display YUV Overlay on SDL_Surface

帅比萌擦擦* 提交于 2019-12-23 04:33:15

问题


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.

Now ffplay can be simplified as below:

  1. Create SDL_Surface *screen from SDL_SetVideoMode()
  2. Create SDL_Overlay *bmp from SDL_CreateYUVOverlay() and associate it with screen

    repeat until video ends

  3. Decode movie frames and populate bmp
  4. Render bmp onto screen using SDL_DisplayYUVOverlay()

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);

and Step 4 as

SDL_DisplayYUVOverlay(bmp, &rect);
SDL_SaveBMP(screen, filenameN); N++;

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.

I am new to SDL, so apart from just the solution, an explanation on why my approach does not work will be helpful.


回答1:


Use SDL_putenv("SDL_VIDEODRIVER=dummy"); to use the dummy video driver, which produces no output.



来源:https://stackoverflow.com/questions/11249998/cannot-display-yuv-overlay-on-sdl-surface

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!