Setting caps for gstbuffer that contains audio,video data of .avi video file

Sree Gowri sreegowris at gmail.com
Fri May 11 09:15:46 PDT 2012


Hi,

I am developing live video streaming application. As application receives
live video streaming buffer periodically from other layers. As first step I
started reading the data from the avi file(format:video/x-msvideo) and
passed the same to gstbuffer .Caps has been set to the buffer before
pushing the data to be played.

However the caps that is set is not successfully playing the video. Below
is the snippet of the code.As of now I have constructed the pipeline only
for the video part.

 Kindly let me know the additions required to play audio,video successfully.

[pipeline code]

    app->src = (GstAppSrc*)gst_element_factory_make("appsrc", "mysrc");
    app->decoder = gst_element_factory_make("decodebin", "mydecoder");
    app->ffmpeg = gst_element_factory_make("ffmpegcolorspace", "myffmpeg");
    app->xvimagesink = gst_element_factory_make("xvimagesink", "myvsink");

[/pipeline code]

[callback for signal "pad-added" for the decoder element]

static void on_pad_added(GstElement *element, GstPad *pad)
{
    GstCaps *caps;
    GstStructure *str;
    gchar *name;
    GstPad *ffmpegsink;
    GstPadLinkReturn ret;

    g_debug("pad added");

    caps = gst_pad_get_caps(pad);
    str = gst_caps_get_structure(caps, 0);
    g_assert(str);
    name = (gchar*)gst_structure_get_name(str);
    g_debug("pad name %s", name);
    if(g_strrstr(name, "video")){

        ffmpegsink = gst_element_get_pad(gst_app.ffmpeg, "sink");
        g_assert(ffmpegsink);
        ret = gst_pad_link(pad, ffmpegsink);
        g_debug("pad_link returned %d\n", ret);
        gst_object_unref(ffmpegsink);
    }
    gst_caps_unref(caps);
}
[/callback for signal "pad-added" for the decoder element]

[caps set for appsrc element]

caps = gst_caps_new_simple ("video/x-xvid",
     "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
     "framerate", GST_TYPE_FRACTION, 25, 1,
     "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
     "width", G_TYPE_INT, 704,
     "height", G_TYPE_INT, 400,
     NULL);

 gst_app_src_set_caps(GST_APP_SRC(app->src), caps);

[/caps set for appsrc element]

If the caps set as "video/x-msvideo" then the error encountered is "Error
The stream is of a different type than handled by this element" and if the
caps set as "video/x-xvid" error encountered is "*** glibc detected ***
./video: double free or corruption (!prev): 0x08192f68 ***"

[Buffer fed to appsrc]

bytes_read = fread(data, 1, BUFF_SIZE,  fp); //Reading data from avi file
pointer.
bytetotal += bytes_read;

buffer= gst_buffer_new();
GST_BUFFER_MALLOCDATA(buffer) = data;
GST_BUFFER_SIZE(buffer)=bytes_read;
GST_BUFFER_DATA(buffer) = GST_BUFFER_MALLOCDATA(buffer);

gst_app_src_push_buffer(app->src, buffer);

[/Buffer fed to appsrc]


Thanks and Regards,
Sree
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20120511/655c92de/attachment.html>


More information about the gstreamer-devel mailing list