[gst-devel] gst-launch v. c launching and flv v. mpeg2

E. Westbrook gstreamer at westbrook.com
Mon Jul 20 06:30:30 CEST 2009


Can someone please help me spot how I'm being stupid?

I can play a FLV file using:

$ gst-launch filesrc location=jerrydog.flv ! ffdemux_flv ! ffdec_flv !
xvimagesink

But when I try to play the same file with the following code, it hangs with
no output.

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

#include <gst/gst.h>

int main(int argc, char** argv) {
  gst_init(&argc, &argv);

  GMainLoop* loop = g_main_loop_new(NULL, FALSE);

  GstPipeline* p = GST_PIPELINE(gst_pipeline_new("pipey"));

  GstElement* src = gst_element_factory_make("filesrc", "filey");
  GstElement* dmx = gst_element_factory_make("ffdemux_flv", "demuxey");
  GstElement* dec = gst_element_factory_make("ffdec_flv", "decodey");
  GstElement* sink = gst_element_factory_make("xvimagesink", "sinky");

  g_object_set(G_OBJECT(src), "location", "jerrydog.flv", NULL);

  gst_bin_add_many(GST_BIN(p), src, dmx, dec, sink, NULL);
  gst_element_link_many(src, dmx, dec, sink, NULL);

  gst_element_set_state(GST_ELEMENT(p), GST_STATE_PLAYING);

  g_main_loop_run(loop);

  return 0;
}

The thing is, I've separately encoded the file to mpeg2, and I can also play
it using:

$ gst-launch filesrc location=jerrydog.mp2 ! mpeg2dec ! xvimagesink

and then, puzzlingly, unlike the FLV version, my C code plays the mpeg2
flavor just great:

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

#include <gst/gst.h>

int main(int argc, char** argv) {
  gst_init(&argc, &argv);

  GMainLoop* loop = g_main_loop_new(NULL, FALSE);

  GstPipeline* p = GST_PIPELINE(gst_pipeline_new("pipey"));
  GstElement* src = gst_element_factory_make("filesrc", "filey");
  GstElement* dec = gst_element_factory_make("mpeg2dec", "decodey");
  GstElement* sink = gst_element_factory_make("xvimagesink", "sinky");

  g_object_set(G_OBJECT(src), "location", "jerrydog.mp2", NULL);

  gst_bin_add_many(GST_BIN(p), src, dec, sink, NULL);
  gst_element_link_many(src, dec, sink, NULL);

  gst_element_set_state(GST_ELEMENT(p), GST_STATE_PLAYING);

  g_main_loop_run(loop);

  return 0;
}

So what's confusing me is, in the FLV case, how am I constructing the
pipeline wrongly in C, in the FLV case anyway, that differs from
gst-launch?  Or am I?  Is this as dumb a question as it seems to me it must
be?

Thanks,
E. Westbrook

PS - All test case source is here exactly as I'm compiling it.  My input
video files are available at:

http://media.westbrook.com/media/jerrydog.flv
http://media.westbrook.com/media/jerrydog.mp2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20090719/4406217c/attachment.htm>


More information about the gstreamer-devel mailing list