[gst-devel] Adding element to pipeline and linking elements failed
Zelalem Sintayehu
zelalems at hotmail.com
Mon Jun 15 13:06:23 CEST 2009
Hi all, I had a command line code to record video from network and it was working fine (it is listed below):
gst-launch udpsrc port=5000 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998" num-buffers=5000 ! queue ! rtph263pdepay ! 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue ! avimux ! queue ! filesink location=test1.avi
So, I wanted to change this into a code so that I wanted to include it in my application and I failed. Please help me. I got an error on the gst_bin_add_many and gst_element_link_many functions. The code is presented below. Please help me. The error is the following:
(videorecorder:19632): GStreamer-CRITICAL **: gst_bin_add: assertion `GST_IS_ELEMENT (element)' failed
(videorecorder:19632): GStreamer-CRITICAL **: gst_element_link_pads_filtered: assertion `GST_IS_ELEMENT (dest)' failed
Thank you.
- Zelalem S.
#include <gst/gst.h>
#include <stdio.h>
int
main (int argc,
char *argv[])
{
GstElement *udpsource, *queue1, *queue2, *queue3, *h263depay, *avimuxer, *filedes, *pipeline;
GstCaps *caps, *caps2;
/* init GStreamer */
gst_init (&argc, &argv);
/* create element */
udpsource = gst_element_factory_make ("udpsrc", "udpsource");
queue1 = gst_element_factory_make ("queue", "queue1");
queue2 = gst_element_factory_make ("queue", "queue2");
// queue3 = gst_element_factory_make ("queue", "queue3");
h263depay = gst_element_factory_make ("rtph263pdepay", "h263depay");
avimuxer = gst_element_factory_make ("avimux", "avimuxer");
filedes = gst_element_factory_make ("filesink", "filedes");
caps = gst_caps_new_simple( "application/x-rtp", "media", G_TYPE_STRING, "video", "clock-rate",
G_TYPE_INT, 90000, "encoding-name", G_TYPE_STRING, "H263-1998", "num-buffers",G_TYPE_INT,5000,NULL);
caps2 = gst_caps_new_simple ("video/x-h263", "width", G_TYPE_INT, 320, "height", G_TYPE_INT, 240,
"framerate", GST_TYPE_FRACTION, 25, 1, NULL);
// g_object_set (G_OBJECT (udpsource), "port", 5000, NULL);
g_object_set (G_OBJECT (udpsource), "port", 5000, "caps", caps, NULL);
g_object_set (G_OBJECT (filedes), "location", "test20.avi", NULL);
// caps2 = gst_caps_new_simple("video/x-h263","width", 320, "height", 240, "framerate", 25, 1,NULL) ;
/* alternative */
pipeline = gst_pipeline_new ("video-pipeline");
if (!pipeline || !udpsource || !queue1 || !queue2 || !h263depay || !avimuxer || !filedes || !caps || !caps2) {
g_printerr ("One of the element could not be created. Exiting.\n");
return -1;
}
//add elements to the pipeline
gst_bin_add_many (GST_BIN (pipeline),
udpsource, queue1, h263depay, caps2, avimuxer, queue2, filedes, NULL);
//link the elements
//gst_element_link_many (udpsource, queue1, h263depay, NULL);
//gst_element_link_many (avimuxer, queue2, filedes, NULL);
gst_element_link_many(udpsource, queue1, h263depay,caps2,avimuxer, queue2, filedes, NULL);
//link two elements with a filter (here h263depay and queue2 with caps2
//gboolean link_ok = gst_element_link_filtered (h263depay, avimuxer, caps2);
//start the pipeline
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20090615/543e21fe/attachment.htm>
More information about the gstreamer-devel
mailing list