Can someone please help me spot how I'm being stupid?<br><br>I can play a FLV file using:<br><br><div style="margin-left: 40px;"><font size="1"><span style="font-family: courier new,monospace;">$ gst-launch filesrc location=jerrydog.flv ! ffdemux_flv ! ffdec_flv ! xvimagesink</span></font><br>
</div><br>But when I try to play the same file with the following code, it hangs with no output.<br><br><div style="margin-left: 40px;"><font size="1"><span style="font-family: courier new,monospace;">#include <unistd.h></span></font><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;">#include <stdio.h></span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;">#include <stdlib.h></span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;">#include <gst/gst.h></span></font><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;">int main(int argc, char** argv) {</span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> gst_init(&argc, &argv);</span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> GMainLoop* loop = g_main_loop_new(NULL, FALSE);</span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> GstPipeline* p = GST_PIPELINE(gst_pipeline_new("pipey"));</span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> GstElement* src = gst_element_factory_make("filesrc", "filey");</span></font><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> GstElement* dmx = gst_element_factory_make("ffdemux_flv", "demuxey");</span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> GstElement* dec = gst_element_factory_make("ffdec_flv", "decodey");</span></font><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> GstElement* sink = gst_element_factory_make("xvimagesink", "sinky");</span></font><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> g_object_set(G_OBJECT(src), "location", "jerrydog.flv", NULL);</span></font><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> gst_bin_add_many(GST_BIN(p), src, dmx, dec, sink, NULL);</span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> gst_element_link_many(src, dmx, dec, sink, NULL);</span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> gst_element_set_state(GST_ELEMENT(p), GST_STATE_PLAYING);</span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> g_main_loop_run(loop);</span></font><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> return 0;</span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;">}</span></font><br style="font-family: courier new,monospace;">
</div><br>The thing is, I've separately encoded the file to mpeg2, and I can also play it using:<br><br><div style="margin-left: 40px;"><font size="1"><span style="font-family: courier new,monospace;">$ gst-launch filesrc location=jerrydog.mp2 ! mpeg2dec ! xvimagesink</span></font><br>
</div><br>and then, puzzlingly, unlike the FLV version, my C code plays the mpeg2 flavor just great:<br><br><div style="margin-left: 40px;"><font size="1"><span style="font-family: courier new,monospace;">#include <unistd.h></span></font><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;">#include <stdio.h></span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;">#include <stdlib.h></span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;">#include <gst/gst.h></span></font><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;">int main(int argc, char** argv) {</span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> gst_init(&argc, &argv);</span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> GMainLoop* loop = g_main_loop_new(NULL, FALSE);</span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> GstPipeline* p = GST_PIPELINE(gst_pipeline_new("pipey"));</span></font><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> GstElement* src = gst_element_factory_make("filesrc", "filey");</span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> GstElement* dec = gst_element_factory_make("mpeg2dec", "decodey");</span></font><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> GstElement* sink = gst_element_factory_make("xvimagesink", "sinky");</span></font><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> g_object_set(G_OBJECT(src), "location", "jerrydog.mp2", NULL);</span></font><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> gst_bin_add_many(GST_BIN(p), src, dec, sink, NULL);</span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> gst_element_link_many(src, dec, sink, NULL);</span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> gst_element_set_state(GST_ELEMENT(p), GST_STATE_PLAYING);</span></font><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;"> g_main_loop_run(loop);</span></font><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<font size="1"><span style="font-family: courier new,monospace;"> return 0;</span></font><br style="font-family: courier new,monospace;"><font size="1"><span style="font-family: courier new,monospace;">}</span></font><br>
</div><br>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?<br>
<br>Thanks,<br>E. Westbrook<br><br>PS - All test case source is here exactly as I'm compiling it. My input video files are available at:<br><br><a href="http://media.westbrook.com/media/jerrydog.flv">http://media.westbrook.com/media/jerrydog.flv</a><br>
<a href="http://media.westbrook.com/media/jerrydog.mp2">http://media.westbrook.com/media/jerrydog.mp2</a><br>
<br>