0

In that last question, I realized I cannot use both SDL and SDL2. Definitely I choose SDL2 over its precedent.

I had written the following code to capture screen and convert it to an AVFrame for video creation:

AVFrame *frame = av_frame_alloc();
...

SDL_Surface *screen = SDL_SetVideoMode(width,height, 0, 0);
SDL_Overlay *bmp = SDL_CreateYUVOverlay(width,height, SDL_YV12_OVERLAY, screen);


if(av_frame_make_writable(frame) < 0)
    exit(1);


SDL_LockYUVOverlay(bmp);
memcpy(frame->data[0], bmp->pixels[0], bmp->pitches[0]);
memcpy(frame->data[1], bmp->pixels[1], bmp->pitches[1]);
memcpy(frame->data[2], bmp->pixels[2], bmp->pitches[2]);
SDL_UnlockYUVOverlay(bmp);

The problem is that SDL2 does not support SDL_Overlay. The alternative methods are good for playing a video not capturing it. How should I modify this code to replace SDL_Overlay and make it suitable for SDL2?

ar2015
  • 5,558
  • 8
  • 53
  • 110
  • For the person who voted to close this question as too broad, I should mention that all libraries can be used in many ways. But the purpose is one. The question is extremely clear. Do you have one solution at all? – ar2015 Nov 20 '17 at 13:47
  • I may not quite understand it but, are you saying `SDL_Overlay *bmp` in above example doesn't have current frame buffer's planar (yuv) data? – the kamilz Nov 21 '17 at 10:41
  • @thekamilz, No. I mean `SDL_Overlay` is obsolete in SDL2 and I should substitute it with something else. Looking for a replacement. – ar2015 Nov 21 '17 at 10:44
  • Now I got it. I'm sure you might seen this one but just in case, did you check this: https://stackoverflow.com/questions/17579286/sdl2-0-alternative-for-sdl-overlay – the kamilz Nov 21 '17 at 10:48
  • @thekamilz, what I need is the reverse of `SDL_UpdateYUVTexture` – ar2015 Nov 21 '17 at 10:50
  • Oh yes, right. OK this is my final try: https://stackoverflow.com/questions/22315980/sdl2-c-taking-a-screenshot . Good luck. – the kamilz Nov 21 '17 at 10:55

0 Answers0