[gst-devel] audioresample

Jesu Anuroop Suresh jesuas at gmail.com
Wed Jan 12 13:41:21 CET 2011


Hi Sean,

Yes, what I was trying is to resample the decoded mp3 data to the fixed
(22KHZ S16LE) formate,

no matter what is the input rate using a C application.

Thanks for your response.

Here is the piece of the code for the same but it does not work  with
audioresample with the caps filter 'resmux'. This code does work without the
caps filter 'resmux'.

        GstElement *source, *demuxer, *decoder, *conv, *sink, *resample,
*resmux;
        GstCaps *caps;

        gst_init(NULL, NULL);

        /* Create gstreamer elements */
        musicPlayer.playPipeline = gst_pipeline_new ("audio-player");
        source   = gst_element_factory_make ("filesrc", "file-source");
        sink     = gst_element_factory_make ("alsasink", "audio-output");
        resample = gst_element_factory_make ("audioresample",
"audio-resample");
        conv     = gst_element_factory_make ("audioconvert",  "converter1");

        caps = gst_caps_new_simple ("audio/x-raw-int",
                                     "width", G_TYPE_INT, 16,
                                     "depth", G_TYPE_INT, 16,
                                     "rate",  G_TYPE_INT, 22050,
                                     "channels",G_TYPE_INT, 2, NULL
                                     );

        if (!musicPlayer.playPipeline || !source || !sink ||
            !resample || !resmux || !caps || !conv)
        {
            g_print ("NO MEM Exiting.\n");
            return 1;
        }

        /* we set the input filename to the source element */
        g_object_set (G_OBJECT (source), "location", filePath, NULL);

        demuxer  = gst_element_factory_make ("id3demux", "id3-demuxer");
        decoder  = gst_element_factory_make ("mad", "mp3-decoder");

         if (!demuxer || !decoder || !conv1)
         {
                    g_print ("NO MEM Exiting.\n");
                    return 1;
          }

         g_object_set (G_OBJECT (resmux), "caps", caps, NULL);
         gst_caps_unref (caps);

         /* file-source -> demuxer -> decoder ->  alsa-output */
        gst_bin_add_many (GST_BIN (musicPlayer.playPipeline),
                         source, demuxer, decoder, conv, resample, resmux,sink,
NULL);

        gst_element_link (source, demuxer);
        gst_element_link_many (decoder, conv, resample,resmux,sink, NULL);

        g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added),
decoder);

        GstBus *bus =
gst_pipeline_get_bus(GST_PIPELINE(musicPlayer.playPipeline));
        gst_bus_add_watch(bus, bus_call, NULL);
        gst_object_unref(bus);

        gst_element_set_state(GST_ELEMENT(musicPlayer.playPipeline),
GST_STATE_PLAYING);

        musicPlayer.playLoop = g_main_loop_new(NULL, FALSE);

        g_main_loop_run(musicPlayer.playLoop);

        gst_element_set_state(GST_ELEMENT(musicPlayer.playPipeline),
GST_STATE_NULL);
        gst_object_unref(GST_OBJECT(musicPlayer.playPipeline));




With Warm Regards
Jesu Anuroop Suresh

"Any intelligent fool can make things bigger, more complex, and more
violent. It takes a touch of genius -- and a lot of courage -- to move in
the opposite direction."
"Anyone who has never made a mistake has never tried anything new."






On Wed, Jan 12, 2011 at 4:31 PM, Sean McNamara-4 [via GStreamer-devel] <
ml-node+3213735-1942695576-203210 at n4.nabble.com<ml-node%2B3213735-1942695576-203210 at n4.nabble.com>
> wrote:

> Hi,
>
> I don't entirely understand your question. Are you trying to convert a
> pipeline into an equivalent C application? Doing so is just based on
> understanding of C and the gstreamer C API... it is certainly possible,
> insofar as your pipeline is valid.
>
> That said, look at gst_parse_* functions for a way to enter a pipeline spec
> in the gst-launch syntax and get either a GstBin or a GstPipeline out of it.
>
> Sean
> On Jan 12, 2011 4:20 AM, "Jesu Anuroop Suresh" <[hidden email]<http://user/SendEmail.jtp?type=node&node=3213735&i=0>>
> wrote:
> >
> > Hi All,
> >
> > Does anyone tried the pipeline for audioresample using C.
> >
> > gst-launch -vvv filesrc location=01_Pepercut.mp3 ! id3demux ! mad !
> > audioconvert ! audioresample !
> >
> audio/x-raw-int,width=16,rate=22050,channels=1,depth=16,signed=true,endianness=1234
> > ! alsasink
> >
> > Thanks and regards
> > Jesu Anuroop Suresh
> >
> > --
> > View this message in context:
> http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3213586.html<http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3213586.html?by-user=t>
> > Sent from the GStreamer-devel mailing list archive at Nabble.com.
> >
> >
> ------------------------------------------------------------------------------
> > Protect Your Site and Customers from Malware Attacks
> > Learn about various malware tactics and how to avoid them. Understand
> > malware threats, the impact they can have on your business, and how you
> > can protect your company and customers by using code signing.
> > http://p.sf.net/sfu/oracle-sfdevnl
> > _______________________________________________
> > gstreamer-devel mailing list
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=3213735&i=1>
>
> > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
> ------------------------------------------------------------------------------
>
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=3213735&i=2>
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
> ------------------------------
>  View message @
> http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3213735.html
> To unsubscribe from audioresample, click here<http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3213586&code=amVzdWFzQGdtYWlsLmNvbXwzMjEzNTg2fDcwOTc3MzYyOA==>.
>
>

-- 
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/audioresample-tp3213586p3213856.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110112/b8aa7683/attachment.htm>


More information about the gstreamer-devel mailing list