<div>Hi,</div>
<div> </div>
<div>You need to check the return status of gst_element_link_many (videosrc, muxer, videoenc, sink,<br> NULL); it may be a failure.</div>
<div> </div>
<div>You may be required to do dynamic linking between mux and decoder.</div>
<div> </div>
<div>-Ashwini</div>
<div><br><br> </div>
<div class="gmail_quote">On Wed, Aug 3, 2011 at 4:25 PM, Durga <span dir="ltr"><<a href="mailto:durgas1987@gmail.com">durgas1987@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi,<br><br>I have identified the below pipleine to play the video.<br><br>gst-launch-0.10 -v filesrc location=/home/administrator/Desktop/Test.mp4 !<br>
qtdemux ! ffdec_mpeg4 ! autovideosink<br><br>With gst-launch i am able to play the video.<br><br>I converted the pipeline to a C Code and tried to play the video but it<br>displays the error:GStreamer General Stream Error.<br>
<br>This is code i am using for testing.<br><br>Code:<br><br>#include &lt;gst/gst.h&gt;<br>#include <glib.h><br><br>static gboolean<br>bus_call (GstBus *bus, GstMessage *msg, gpointer data)<br>{<br> GMainLoop *loop = (GMainLoop *) data;<br>
<br> switch (GST_MESSAGE_TYPE (msg)) {<br><br> case GST_MESSAGE_EOS:<br> g_print ("End of stream\n");<br> g_main_loop_quit (loop);<br> break;<br><br> case GST_MESSAGE_ERROR: {<br> gchar *debug;<br>
GError *error;<br><br> gst_message_parse_error (msg, &error, &debug);<br> g_free (debug);<br><br> g_printerr ("Error: %s\n", error->message);<br> g_error_free (error);<br><br> g_main_loop_quit (loop);<br>
break;<br> }<br> default:<br> break;<br> }<br><br> return TRUE;<br>}<br><br>int<br>main (int argc, char *argv[])<br>{<br> GMainLoop *loop;<br><br> GstElement *pipeline, *videosrc, *colorspace, *videoenc,<br> *videoq, *audiosrc, *conv, *audioenc, *audioq, *muxer, *sink;<br>
<br> GstBus *bus;<br><br> /* Initialisation */<br> gst_init ((NULL, NULL);<br><br> loop = g_main_loop_new (NULL, FALSE);<br><br> /* Create gstreamer elements */<br> pipeline = gst_pipeline_new ("audio-player");<br>
videosrc = gst_element_factory_make ("filesrc", "videosrc");<br> muxer = gst_element_factory_make ("qtdemux", "mux");<br> videoenc = gst_element_factory_make ("ffdec_mpeg4", "videoenc");<br>
sink = gst_element_factory_make ("autovideosink", "sink");<br><br> if (!pipeline || !videosrc || !muxer || !videoenc<br> || !sink) {<br> g_printerr ("One element could not be created. Exiting.\n");<br>
return -1;<br> }<br><br> /* Set up the pipeline */<br> g_print ("Elements are created\n");<br><br> /* set the properties of other elements */<br> g_object_set (G_OBJECT (videosrc), "location",<br>"/home/administrator/Desktop/Test.mp4", NULL);<br>
<br> /* we add a message handler */<br> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br> gst_bus_add_watch (bus, bus_call, loop);<br> gst_object_unref (bus);<br><br> /* we add all elements into the pipeline */<br>
gst_bin_add_many (GST_BIN (pipeline),<br> videosrc, muxer, videoenc,<br> sink, NULL);<br><br> g_print ("Added all the Elements into the pipeline\n");<br><br> /* we link the elements together */<br> gst_element_link_many (videosrc, muxer, videoenc, sink,<br>
NULL);<br><br> g_print ("Linked all the Elements together\n");<br> /* Set the pipeline to "playing" state*/<br> g_print ("Playing the video\n");<br> gst_element_set_state (pipeline, GST_STATE_PLAYING);<br>
<br> /* Iterate */<br> g_print ("Running...\n");<br> g_main_loop_run (loop);<br><br> /* Out of the main loop, clean up nicely */<br> g_print ("Returned, stopping playback\n");<br> gst_element_set_state (pipeline, GST_STATE_NULL);<br>
<br> g_print ("Deleting pipeline\n");<br> gst_object_unref (GST_OBJECT (pipeline));<br><br> return 0;<br>}<br><br>Please let me know if there is any error in the code.<br><br>Thanks in advance.<br><font color="#888888"><br>
--<br>View this message in context: <a href="http://gstreamer-devel.966125.n4.nabble.com/GStreamer-C-Code-to-play-video-tp3715064p3715064.html" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/GStreamer-C-Code-to-play-video-tp3715064p3715064.html</a><br>
Sent from the GStreamer-devel mailing list archive at Nabble.com.<br>_______________________________________________<br>gstreamer-devel mailing list<br><a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br></font></blockquote></div><br>