How to set audio format in code

Jim restlessmindsstudio at gmail.com
Thu Feb 28 09:45:40 PST 2013


Great that worked. Thanks for your help, Tim!

Jim

-----Original Message-----
From: gstreamer-devel-bounces+restlessmindsstudio=gmail.com at lists.freedesktop.org [mailto:gstreamer-devel-bounces+restlessmindsstudio=gmail.com at lists.freedesktop.org] On Behalf Of Tim-Philipp Müller
Sent: Thursday, February 28, 2013 9:57 AM
To: gstreamer-devel at lists.freedesktop.org
Subject: Re: How to set audio format in code

On Thu, 2013-02-28 at 09:46 -0700, Jim wrote:
> In the following gst-launch command line, right before the alsasink 
> element, the audio format is being specified:
>
> gst-launch filesrc location=video.ts typefind=true ! flutsdemux 
> name=demux demux. ! queue max-size-buffers=0 max-size-time=0 !
> vpudec ! mfw_v4lsink demux. ! queue max-size-buffers=0
> max-size-time=0 ! beepdec ! audioconvert ! 'audio/x-raw-int, 
> channels=2' ! alsasink
> 
> 
> How would I specify the audio format in my C code? Since this is 
> separated with an exclamation point (!) in the command line, it seems 
> like a separate element so I tried:
> 
> gst_element_factory_make("audio/x-raw-int, channels=2", 
> "myAudioFormat");
> 
> but that didn’t work.

That .. ! caps ! .. notation is a shortcut for a capsfilter element with the given caps.

GstElement *capsfilter = gst_element_factory_make("capsfilter", NULL); GstCaps *caps = gst_caps_from_string("audio/x-raw-int,channels=2");
g_object_set (capsfilter, "caps", caps, NULL); gst_caps_unref (caps);

Cheers
 -Tim

PS: there's also gst_parse_launch() to create a complete pipeline from a string like in gst-launch.





_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list