segmentation fault in playing gstreamer pipeline
Srinath, Kamaldeep
kasrinat at akamai.com
Fri Sep 5 09:51:01 PDT 2014
On 9/5/14, 5:35 PM, "Mayank Agarwal" <mayank77fromindia at gmail.com> wrote:
> Hi,
>
> I have written a simple application to play webm file below.
>
> #include <gst/gst.h>
>> #include <glib.h>
>
>
> static gboolean
> bus_call (GstBus *bus,
> GstMessage *msg,
>> gpointer data)
> {
> GMainLoop *loop = (GMainLoop *) data;
>
> switch (GST_MESSAGE_TYPE (msg)) {
>
> case GST_MESSAGE_EOS:
> g_print ("End of stream\n");
> g_main_loop_quit (loop);
> break;
>
> case GST_MESSAGE_ERROR: {
> gchar *debug;
> GError *error;
>
> gst_message_parse_error (msg, &error, &debug);
> g_free (debug);
>
> g_printerr ("Error: %s\n", error->message);
> g_error_free (error);
>
> g_main_loop_quit (loop);
> break;
> }
>
>
> default:
> break;
> }
>
> return TRUE;
>}
>
>
>
>
> int main(int argc,char *argv[])
> {
>
> GMainLoop *loop;
> GstElement *htpsrc,*demuxer,*decoder,*ffmpeg,*sink;
> GstElement *pipeline;
> GstBus *bus;
> guint bus_watch_id;
>
> gst_init(&argc,&argv);
>
> loop = g_main_loop_new (NULL, FALSE);
>
> htpsrc = gst_element_factory_make("filesrc","htonesrc");
>
> demuxer = gst_element_factory_make("matroskademux","demux");
>
> decoder = gst_element_factory_make("vp8dec","vp8decoder");
>
> ffmpeg = gst_element_factory_make("ffmpegcolorspace","httpsrc");
>
> sink = gst_element_factory_make("ximagesink","httpsrc");
>
> if(!htpsrc)
> {
> g_print("source element could not be created\n");
> return;
> }
>
> if(!demuxer)
> {
> g_print("demuxer element could not be created\n");
> return;
> }
>
> if(!decoder)
> {
> g_print("decoder element could not be created\n");
> return;
> }
>
>
> if(!ffmpeg)
> {
> g_print("ffmpeg element could not be created\n");
> return;
> }
>
>
> if(!sink)
> {
> g_print("sink element could not be created\n");
> return;
> }
>
> g_print("before creating pipeline \n");
> pipeline = gst_pipeline_new("basic_player");
> if(!pipeline)
> {
> g_printf("Pipeline could not be created");
> return;
> }
>
>
> g_object_set (G_OBJECT (htpsrc), "location", argv[1], NULL);
>
> bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
> bus_watch_id = gst_bus_add_watch(bus,bus_call,loop);
> gst_object_unref(loop);
>
> gst_bin_add_many(GST_BIN (pipeline),htpsrc,demuxer,decoder,ffmpeg,sink);
>
> gst_element_link_many(htpsrc,demuxer,decoder,ffmpeg,sink);
>
> gst_element_set_state(pipeline,GST_STATE_PLAYING);
>
> g_print ("Rundsning...\n");
> g_main_loop_run (loop);
>
> g_print ("Returned, stopping playback\n");
> gst_element_set_state (pipeline, GST_STATE_NULL);
>
> g_print ("Deleting pipeline\n");
> gst_object_unref (GST_OBJECT (pipeline));
> g_source_remove (bus_watch_id);
> g_main_loop_unref (loop);
>
> return 0;
>
>
> on running the executable i am getting the following error:
> exampleone:20144): GStreamer-CRITICAL **: gst_object_unref: assertion
> `((GObject *) object)->ref_count > 0' failed
>
> (exampleone:20144): GStreamer-WARNING **: Name 'httpsrc' is not unique
> in bin 'basic_player', not adding
> Segmentation fault (core dumped)
>
> while the following pipeline is running fine:
>
> gst-launch souphttpsrc location=
>http://video.webmfiles.org/big-buck-bunny_trailer.webm ! matroskademux
>! vp8dec ! ffmpegcolorspace ! ximagesink
>
>Please find complete log below:
>
>
>
>:00:00.316319426 20230 0x1f65600 INFO GST_INIT
>gst.c:456:gst_init_check: initialized GStreamer successfully
>0:00:00.317857074 20230 0x1f65600 INFO GST_PLUGIN_LOADING
>gstplugin.c:859:gst_plugin_load_file: plugin
>"/usr/lib/x86_64-linux-gnu/gstreamer-0.10/libgstcoreelements.so"
>loaded
>0:00:00.318031251 20230 0x1f65600 INFO GST_ELEMENT_FACTORY
>gstelementfactory.c:374:gst_element_factory_create: creating element
>"filesrc" named "htonesrc"
>0:00:00.318548875 20230 0x1f65600 INFO GST_ELEMENT_PADS
>gstelement.c:728:gst_element_add_pad:<GstBaseSrc at 0x22a0080> adding pad
>'src'
>0:00:00.320590434 20230 0x1f65600 INFO GST_PLUGIN_LOADING
>gstplugin.c:859:gst_plugin_load_file: plugin
>"/usr/lib/x86_64-linux-gnu/gstreamer-0.10/libgstmatroska.so" loaded
>0:00:00.320789972 20230 0x1f65600 INFO GST_ELEMENT_FACTORY
>gstelementfactory.c:374:gst_element_factory_create: creating element
>"matroskademux" named "demux"
>0:00:00.321194515 20230 0x1f65600 INFO GST_ELEMENT_PADS
>gstelement.c:728:gst_element_add_pad:<GstMatroskaDemux at 0x22a8060>
>adding pad 'sink'
>0:00:00.323143688 20230 0x1f65600 INFO GST_PLUGIN_LOADING
>gstplugin.c:859:gst_plugin_load_file: plugin
>"/usr/lib/x86_64-linux-gnu/gstreamer-0.10/libgstvp8.so" loaded
>0:00:00.323336250 20230 0x1f65600 INFO GST_ELEMENT_FACTORY
>gstelementfactory.c:374:gst_element_factory_create: creating element
>"vp8dec" named "vp8decoder"
>0:00:00.323779132 20230 0x1f65600 INFO GST_ELEMENT_PADS
>gstelement.c:728:gst_element_add_pad:<GstBaseVideoCodec at 0x22adbf0>
>adding pad 'sink'
>0:00:00.323973401 20230 0x1f65600 INFO GST_ELEMENT_PADS
>gstelement.c:728:gst_element_add_pad:<GstBaseVideoCodec at 0x22adbf0>
>adding pad 'src'
>0:00:00.324577863 20230 0x1f65600 INFO GST_PLUGIN_LOADING
>gstplugin.c:859:gst_plugin_load_file: plugin
>"/usr/lib/x86_64-linux-gnu/gstreamer-0.10/libgstffmpegcolorspace.so"
>loaded
>0:00:00.324746060 20230 0x1f65600 INFO GST_ELEMENT_FACTORY
>gstelementfactory.c:374:gst_element_factory_create: creating element
>"ffmpegcolorspace" named "httpsrc"
>0:00:00.325943932 20230 0x1f65600 INFO GST_ELEMENT_PADS
>gstelement.c:728:gst_element_add_pad:<GstBaseTransform at 0x22be040>
>adding pad 'sink'
>0:00:00.329914803 20230 0x1f65600 INFO GST_ELEMENT_PADS
>gstelement.c:728:gst_element_add_pad:<GstBaseTransform at 0x22be040>
>adding pad 'src'
>0:00:00.331701414 20230 0x1f65600 INFO GST_PLUGIN_LOADING
>gstplugin.c:859:gst_plugin_load_file: plugin
>"/usr/lib/x86_64-linux-gnu/gstreamer-0.10/libgstximagesink.so" loaded
>0:00:00.332159464 20230 0x1f65600 INFO GST_ELEMENT_FACTORY
>gstelementfactory.c:374:gst_element_factory_create: creating element
>"ximagesink" named "httpsrc"
>0:00:00.332686392 20230 0x1f65600 INFO GST_ELEMENT_PADS
>gstelement.c:728:gst_element_add_pad:<GstBaseSink at 0x22c4400> adding
>pad 'sink'
>before creating pipeline
>0:00:00.333075046 20230 0x1f65600 INFO GST_ELEMENT_FACTORY
>gstelementfactory.c:374:gst_element_factory_create: creating element
>"pipeline" named "basic_player"
>0:00:00.333361625 20230 0x1f65600 INFO filesrc
>gstfilesrc.c:374:gst_file_src_set_location: filename : location=
>0:00:00.337114305 20230 0x1f65600 INFO filesrc
>gstfilesrc.c:375:gst_file_src_set_location: uri :
>file:///home/ubuntu/gstreamer/5sept/location=
>
>(exampleone:20230): GStreamer-CRITICAL **: gst_object_unref: assertion
>`((GObject *) object)->ref_count > 0' failed
>
>(exampleone:20230): GStreamer-WARNING **: Name 'httpsrc' is not unique
>in bin 'basic_player', not adding
>[2]+ Done gedit debugfile.txt
>Segmentation fault (core dumped)
>
>
>
>
>Regards,
>Mayank
There seem to be errors in your sample app. To start with:
ffmpeg = gst_element_factory_make("ffmpegcolorspace","httpsrc");
sink = gst_element_factory_make("ximagesink","httpsrc");
Name them differently and appropriately. Consider using autovideoconvert
too instead of ffmpegcolorspace.
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
bus_watch_id = gst_bus_add_watch(bus,bus_call,loop);
gst_object_unref(loop);
Unref Œbus¹ here and not the loop.
The app writers¹ guide would be useful too.
Thanks
Kamal
>_______________________________________________
>gstreamer-devel mailing list
>gstreamer-devel at lists.freedesktop.org
>http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list