[SDL] SDl 2.0 and ffmpeg
Dimitris Zenios
dimitris.zenios at gmail.com
Fri Mar 9 02:27:35 PST 2012
Have a look at this.
http://slouken.blogspot.com/2011/02/mpeg-acceleration-with-glsl.html
It might help you
Zenios
On Fri, Mar 9, 2012 at 12:09 PM, David martin <vilanew at gmail.com> wrote:
> Hi,
> I'm new to SDL2, I used to play with danger ffmpeg tutorials to stream video
> to an SDL surface.
>
> I'm updating my program incorporating SDL2.
>
>
> Here is a piece of snippet and would appreciate your help to actually draw
> the video image into the surface using the SDL2 api.
> thanks
>
>
>
> ....
> AVFrame* frame ;
> AVPacket avpacket;
> int frame_finished;
> SDL_Event event;
> int w = 640;
> int h = 480;
> int done = 0, color = 0;
> SDL_Window * window = SDL_CreateWindow("SDL", SDL_WINDOWPOS_UNDEFINED,
> SDL_WINDOWPOS_UNDEFINED, w, h, 0);
> SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, 0);
> SDL_Log("+++++ INIT DONE +++++");
>
> frame = avcodec_alloc_frame();
>
> while (av_read_frame(format_context, &avpacket) >= 0) {
> if (avpacket.stream_index == videostream) {
>
> avcodec_decode_video2(codec_context, frame,
> &frame_finished, &avpacket);
>
>
>
> }
>
>
>
> while (!done) {
> SDL_WaitEvent(&event);
>
> switch(event.type) {
> //case FF_ALLOC_EVENT:
> //alloc_picture(event.user.data1);
> // break;
> //case FF_REFRESH_EVENT:
> //video_refresh_timer(event.user.data1);
> // break;
> case SDL_KEYDOWN:
> case SDL_KEYUP:
> //case SDL_MOUSEBUTTONDOWN:
> case SDL_QUIT:
> done=1;
> SDL_Log("Unhandled event type=%d", event.type);
>
> }
>
> //Draw Image into renderer.
> //We used to do it through SDL_DisplayYUVOverlay. How to do that with
> SDL2.0. Any help for this part ?
>
> SDL_RenderClear(renderer);
> SDL_RenderPresent(renderer);
> SDL_Delay(20);
> }
>
> }//while av_read_frame
>
> SDL_Log("+++++ FINISHED +++++");
> SDL_Quit();
> }
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
More information about the SDL
mailing list