Read frame from Gstreamer buffer to SDL_Texture

Chuck Crisler ccrisler at mutualink.net
Fri Mar 7 13:52:39 PST 2014


What OS? What version of GStreamer?

Enable logging (export GST_DEBUG=*:3 or something) and do some digging.
Something must be failing.


On Thu, Mar 6, 2014 at 6:07 AM, kj192 <elte.kissjanos at gmail.com> wrote:

> Hi Everyone,
>
> I would like to have help from You. I (try to) use gstreamer to play video
> in SDL 2. Here is the code of my function where I want to update
> SDL_Texture:
>
> static GstFlowReturn on_buffer (GstAppSink * sink, gpointer user_data)
> {
>   GstBuffer* sample = gst_app_sink_pull_buffer(sink);
>   GstCaps* caps = gst_buffer_get_caps (sample);
>   if (!caps) g_print ("could not get snapshot format\n");
>   GstStructure* s = gst_caps_get_structure (caps, 0);
>   gint width, height;
>   int res = gst_structure_get_int (s, "width", &width)  |
> gst_structure_get_int (s, "height", &height);
>   if (!res) g_print ("could not get snapshot dimension\n");
>   //printf("caps struct=%s\n", gst_caps_to_string(caps));
>
>   SDL_Rect r{0, 0, width, height};
>   SDL_Texture *tex = SDL_CreateTexture(RENDER, SDL_PIXELFORMAT_IYUV,
> SDL_TEXTUREACCESS_STREAMING, width, height);
>
>   if (SDL_UpdateTexture(tex, &r,GST_BUFFER_DATA(sample),(width*4)) == 0)
>   {
>       printf("ok texture update\n");
>   }
>   else
>   {
>        printf("SDL_textureupdate failed: %s\n", SDL_GetError());
>   }
>
>   if ( SDL_RenderCopyEx(RENDER, tex, NULL, &r,ROTATION,NULL,SDL_FLIP_NONE)
> == 0)
>   {
>       printf("ok rendercopy \n");
>   }
>   else
>   {
>        printf("SDL_ rendercopy failed: %s\n", SDL_GetError());
>   }
>
>   SDL_RenderPresent(RENDER);
>   gst_buffer_unref(sample);
>   SDL_DestroyTexture(tex);
>   sleep(0.5);
>   return GST_FLOW_OK;
> }
>
> I don't have any error, but there is nothing in my screen. The Gstreamer
> Appsink seems to be working, because the video what I play is 2 seconds
> 30FPS and the on_buffer callback is being called 60 times.
>
> complete code <http://pastebin.com/8SXhZZw2>
>
> Looking forward to your answers kj192
>
>
>
> --
> View this message in context:
> http://gstreamer-devel.966125.n4.nabble.com/Read-frame-from-Gstreamer-buffer-to-SDL-Texture-tp4665787.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140307/11bc3944/attachment.html>


More information about the gstreamer-devel mailing list