[gst-devel] Playing Mp3 help

Lukas Ruetz lukas.ruetz at gmx.at
Thu Nov 19 11:44:10 CET 2009


Hi,

Am Donnerstag, den 19.11.2009, 07:41 -0200 schrieb Tiago Katcipis:
> It would be easier if you show your on_pad_added function, and if you
> tell exactly what error messages do you get when you run your
> application.
> 
> To investigate the capabilities of a element you can use gst-inspect. 
> 
> On a terminal you can type for example:
> gst-inspect flump3dec
> 
> it will give an complete specification of the flump3dec element.
> 
> best regards,
> Katcipis
> 
> On Thu, Nov 19, 2009 at 6:40 AM, basavaraj P <basavarajp82 at gmail.com>
> wrote:
>         Hello,
>         
>         Following is code which plays mp3 using playbin
>         
>           /* set up */
>           play = gst_element_factory_make ("playbin2", "play");
>           g_object_set (G_OBJECT (play), "uri",
>         "file:///home/basavaraj/Music/JabSeTereNaina.mp3", NULL);
>         
>           bus = gst_pipeline_get_bus (GST_PIPELINE (play));
>         //  gst_bus_add_watch (bus, my_bus_callback, loop);
>           gst_object_unref (bus);
>         
>           gst_element_set_state (play, GST_STATE_PLAYING);
>         
>         
>         Following is code which does not play mp3. Please help me what
>         all plugins we need to connect and 
>         how to find their capabilities
>         
>           /* Create gstreamer elements */
>           GstElement* pipeline = gst_pipeline_new ("audio-player");
>           GstElement* source   = gst_element_factory_make ("filesrc",
>         "file-source");
>           GstElement* demuxer  = gst_element_factory_make
>         ("mpegdemux2",      "mpeg-demuxer");
>           GstElement* decoder  = gst_element_factory_make
>         ("flump3dec",     "fluendo-decoder");
>         //  GstElement* decoder =
>         gst_element_factory_make("decodebin", "decoderbin");
>           GstElement* conv     = gst_element_factory_make
>         ("audioconvert",  "converter");
>           GstElement* sink     = gst_element_factory_make
>         ("autoaudiosink", "audio-output");
>         
>           if (!pipeline || !source || !demuxer || !decoder || !conv
>         || !sink) {
>             g_printerr ("One element could not be created.
>         Exiting.\n");
>             return -1;
>           }
>         
>           /* Set up the pipeline */
>         
>           /* we set the input filename to the source element */
>         //  g_object_set (G_OBJECT (source), "uri",
>         "file:///home/basavaraj/Music/Jab.mp3", NULL);
>           g_object_set (G_OBJECT (source), "location",
>         "/home/basavaraj/Music/Jab.mp3", NULL);
>         
>           /* we add a message handler */
>           GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE
>         (pipeline));
>           gst_bus_add_watch (bus, bus_call, loop);
>           gst_object_unref (bus);
>         
>           /* we add all elements into the pipeline */
>           /* file-source | mp3-demuxer | mp3-decoder | converter |
>         alsa-output */
>           gst_bin_add_many (GST_BIN (pipeline),
>                             source, demuxer, decoder, conv, sink,
>         NULL);
>         
>           /* we link the elements together */
>           /* file-source -> mp3-demuxer ~> mp3-decoder -> converter ->
>         alsa-output */
>           gst_element_link (source, demuxer);
>           g_signal_connect (demuxer, "pad-added", G_CALLBACK
>         (on_pad_added), decoder);
>         
>           /* Set the pipeline to "playing" state*/
>           g_print ("Now playing: %s\n", argv[1]);
>           gst_element_set_state (pipeline, GST_STATE_PLAYING);
>         
>         
>         Thanks in advance,
>         Basavaraj


Try this pipeline to play mp3s. Because it's audio-only (beside 
mp3-tags) you don't need a demuxer.

gst-launch-0.10 -v filesrc location=song.mp3 ! mp3parse ! flump3dec !
audioconvert ! audioresample ! autoaudiosink

hth,
lukas






More information about the gstreamer-devel mailing list