AW: Convert pipeline to C code to play .mov video

Thornton, Keith keith.thornton at zeiss.com
Tue Mar 10 08:40:59 PDT 2015


The decoder needs dynamic pads. Read the chapter in the application developers manual about dynamic sometimes pads.

-----Ursprüngliche Nachricht-----
Von: gstreamer-devel [mailto:gstreamer-devel-bounces at lists.freedesktop.org] Im Auftrag von Raheeb
Gesendet: Dienstag, 10. März 2015 16:01
An: gstreamer-devel at lists.freedesktop.org
Betreff: Convert pipeline to C code to play .mov video

Hi I am trying to convert the following pipeline to C code. There is no error but I am unable to play the video through my code. The below pipeline plays the video but the my code does not. Can someone correct me with the code. Here is my pipeline

gst-launch-1.0 filesrc location=/path/a.mov ! qtdemux ! avdec_h264 ! xvimagesink

Here is my code

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 *pipeline, *source, *demuxer, *decoder, *xvsink;

GstBus *bus;

guint bus_watch_id;

gst_init (&argc, &argv);

loop = g_main_loop_new (NULL, FALSE);

/* Check input arguments */

if (argc != 2) {

g_printerr ("Usage: %s \n", argv[0]);

return -1;

}

/* Create gstreamer elements */ pipeline = gst_pipeline_new ("video-send");

source = gst_element_factory_make ("filesrc", "file-source");

g_assert (source);

demuxer = gst_element_factory_make ("qtdemux", "demuxer");

g_assert (demuxer);

decoder = gst_element_factory_make ("avdec_h264", "decoder");

g_assert (decoder);

xvsink = gst_element_factory_make ("xvimagesink", "video-output");

g_assert (xvsink);

g_object_set (G_OBJECT (source), "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 (bus);

gst_bin_add_many (GST_BIN (pipeline), source, demuxer, decoder, xvsink, NULL);

if(!gst_element_link (source, demuxer))

{

g_printerr ("Here is the problem 1.\n");

}

if(!gst_element_link_many (decoder, xvsink, NULL))

{

g_printerr ("Here is the problem too.\n");

}

g_print ("Now playing: %s\n", argv[1]);

gst_element_set_state (pipeline, GST_STATE_PLAYING);

g_print ("Running...\n");

g_main_loop_run (loop);

/* Out of the main 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;

}


_______________________________________________
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