Note that there are some explanatory texts on larger screens.

plurals
  1. POError in a simple gstreamer code to play an "mp3" audio file
    text
    copied!<pre><code>#include &lt;gst/gst.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int main(int argc, char *argv[]) { GstElement *element; GstElement *element1; GstElement *element2; GstElement *pipeline; gst_init(&amp;argc, &amp;argv); if(argc != 2) { g_print("usage: %s argv[1] \n", argv[0]); exit(EXIT_FAILURE); } /* Creating a new pipeline */ pipeline = gst_pipeline_new("pipeline"); /* creating a new *.mp3 source element */ element = gst_element_factory_make("filesrc", "source"); if(element != NULL) g_object_set(G_OBJECT(element), "location", argv[1], NULL); else { g_print("Failed to create element \n"); exit(EXIT_FAILURE); } /* creating a new *.mp3 de-coder element */ element1 = gst_element_factory_make("decodebin2", "decoder"); if(element1 != NULL) g_print("element1 success \n"); else { g_print("Failed to create element1 \n"); exit(EXIT_FAILURE); } /* creating a new *.mp3 sink element */ element2 = gst_element_factory_make("autoaudiosink", "play_audio"); if(element2 != NULL) g_print("element2 success \n"); else { g_print("Failed to create element2 \n"); exit(EXIT_FAILURE); } /* Adding elements to pipeline */ gst_bin_add_many(GST_BIN(pipeline), element, element1, element2, NULL); /* Linking src to sink element */ gst_element_link_many(element, element1, element2, NULL); /* start playing */ gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING); while(gst_bin_iterate_recurse(GST_BIN(pipeline))); /* stop playing */ gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL); /* un-referencing all the elements in the pipeline */ gst_object_unref(GST_OBJECT(pipeline)); return 0; } </code></pre> <p>1) Compilation step:- gcc gst6.c -o gst6 <code>pk-config --cflags --libs gstreamer-0.10</code>, it is compiling without any warnings and errors.<br> 2) Exported PKG_CONFIG_PATH env variable i.e. export PKG_CONFIG_PATH=/usr/lin/pkgconfig. 3) Execution step: ./gst6 /home/user/Downloads/*.mp3 4) Output: element1 success, element2 success<br> killed.</p> <p>Unable to play the audio file. Please let me know whats wrong in my program. This is my first program.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload