gst-launch v. c launching and flv v. mpeg2

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

gst-launch v. c launching and flv v. mpeg2

E. Westbrook-4
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


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst-launch v. c launching and flv v. mpeg2

Sudarshan Bisht
Hi 
 
   You can not link demuxer and decoder using gst_element_link_many(src, dmx, dec, sink, NULL) function . You need to link these two elements in callback function  because demuxer has to create these pads dynamically.

On Mon, Jul 20, 2009 at 10:00 AM, E. Westbrook <[hidden email]> wrote:
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


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




--
Regards,

Sudarshan Bisht

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst-launch v. c launching and flv v. mpeg2

E. Westbrook-4
That did it, thanks very much indeed.  Your response also helped me find the example in the "decodebin" section of the developer documentation that refers to this method of pad connection.

Connecting the 'new-decoded-pad' signal from the decoder to a callback, which then links the decoder to the sink when a pad is ready, does the trick quite nicely (and I presume, now, correctly).

Thanks again, and by the way thanks also to everyone helping out the newbs like me on this list.  Sure, even the newbs around here still seem to generally have some pretty good chops, but it's always nice to get a nudge when you're stuck. :)

Thanks again and take care,
E. Westbrook

On Mon, Jul 20, 2009 at 12:10 AM, sudarshan bisht <[hidden email]> wrote:
Hi 
 
   You can not link demuxer and decoder using gst_element_link_many(src, dmx, dec, sink, NULL) function . You need to link these two elements in callback function  because demuxer has to create these pads dynamically.

On Mon, Jul 20, 2009 at 10:00 AM, E. Westbrook <[hidden email]> wrote:
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


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




--
Regards,

Sudarshan Bisht

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel