[gst-devel] Playing Mp3 help
Jyoti
jyoti.d at allaboutif.com
Thu Nov 19 12:06:55 CET 2009
Case 1:
The below pipeline should play any mp3 file.
gst-launch -v filesrc location=song.mp3 ! mad ! audioconvert ! audioresample
! autoaudiosink
Case 2:
And optionally if the file has id3 tags then use
gst-launch -v filesrc location=song.mp3 ! id3demux ! mad ! audioconvert !
audioresample ! autoaudiosink
You need to additional install mad(mp3 decoder).
Only in case 2 you need to have the callback for "pad-added" signal. Check
out the helloworld example and similar
from manual.
On Thu, Nov 19, 2009 at 4:14 PM, Lukas Ruetz <lukas.ruetz at gmx.at> wrote:
> 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
>
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20091119/d47bb1fc/attachment.htm>
More information about the gstreamer-devel
mailing list