问题
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:
- Create
SDL_Surface *screen
fromSDL_SetVideoMode()
Create
SDL_Overlay *bmp
fromSDL_CreateYUVOverlay()
and associate it withscreen
repeat until video ends
- Decode movie frames and populate bmp
- 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