[SDL] SDl 2.0 and ffmpeg
David martin
vilanew at gmail.com
Fri Mar 9 06:02:05 PST 2012
Thanks for the link.
I'm reading a video streaming (not a single BMp image) so not sure how
this applies to my code.
ffmpeg reads in in yuvp42 format (see output from ffmpeg dump_format)
> ~/workspace/test1/Release $ ./test2 toto.mpeg
Input #0, mpeg, from 'toto.mpeg':
Duration: 00:00:04.83, start: 1.000000, bitrate: 606 kb/s
Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [SAR
178:163 DAR 1958:1467], 104857 kb/s, 60 fps, 60 tbr, 90k tbn, 60 tbc
So the question is do i need to create a surface from each image read
frame ? How would you do that ?
thanks,
On 03/09/2012 11:27 AM, Dimitris Zenios wrote:
> 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