So I've been trying to go through the following tutorial on ffmpeg: http://dranger.com/ffmpeg/tutorial02.html
However, when I try to compile using gcc, I get the following output:
root:/Users/mbrodeur/Downloads/HACKATHON CONTENT/Tutorials-> gcc -o tutorial02 tutorial02.c -lavutil -lavformat -lavcodec -lz -lavutil -lm -lswscale -D_THREAD_SAFE -lSDL2
tutorial02.c: In function ‘main’:
tutorial02.c:41: error: ‘SDL_Overlay’ undeclared (first use in this function)
tutorial02.c:41: error: (Each undeclared identifier is reported only once
tutorial02.c:41: error: for each function it appears in.)
tutorial02.c:41: error: ‘bmp’ undeclared (first use in this function)
tutorial02.c:98: warning: assignment makes pointer from integer without a cast
tutorial02.c:110: error: ‘SDL_YV12_OVERLAY’ undeclared (first use in this function)
Now, I read that SDL_Overlay is no longer used in SDL2, so therein lies the problem. I've been poking around, but can't seem to find anything helpful. Is there a replacement for SDL_Overlay? Is it necessary?
SDL_Overlay is used in the following context:
SDL_Overlay *bmp;
bmp = SDL_CreateYUVOverlay(pCodecCtx->width, pCodecCtx->height,
SDL_YV12_OVERLAY, screen);
I have updated the tutorial to work with SDL 2.0.1. It replaces SDL_Overlay with SDL_Texture in YV12 format.
I got this problem too. I used SDL 1.2 since I didn't know how to replace SDL_Overlay in SDL2.0. If you are on Mac 10.10, you can use this patch http://www.emaculation.com/doku.php/compiling_sheepshaver_basilisk#tidbits
patch < no-CGDirectPaletteRef.patch
Then in /src/video/x11/SDL_x11sym.h, replace line 168 and 169 to thisSDL_X11_SYM(int,_XData32,(Display *dpy,register _Xconst long *data,unsigned len),(dpy,data,len),return) SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,len), return)
It worked with me.
Try
SDL_CreateTexture()
with a YUV pixel format that matches the layout and planar-ity of your decoded frames.Or use
libswscale
to convertffmpeg
's YUV buffers to RGB.EDIT: SDL2 >= 2.0.1 has
SDL_UpdateYUVTexture()
for updating planar YUV textures so you don't have to manually coalescelibav
's buffers any more.The tutorial https://github.com/chelyaev/ffmpeg-tutorial links against SDL1 http://www.libsdl.org/download-1.2.php and they should have mentioned it(or they did and I haven't seen it).All works perfectly with SDL1.