Professional Documents
Culture Documents
Yocto_gstreamer_audio inst
Yocto_gstreamer_audio inst
[=#audio]
= Audio =
This page will attempt to give examples of audio-based GStreamer pipelines using
GStreamer-1.0, with 'enhanced' encoders and decoders from the gstreamer-imx set of
plugins. Note that 'enhanced' just means that the software algorithms are
especially tuned for the imx6 family.
[=#gstreamer-alsa]
== GStreamer alsasrc and alsasink ==
The GStreamer {{{alsasrc}}} and {{{alsasink}}} provide audio capture and playback
to Advanced Linux Sound Architecture (ALSA) devices. ALSA is the modern device-
driver API for the Linux kernel.
The Gstreamer alsasrc and alsasink can be passed a {{{device}}} property which can
represent either the device name (reported from {{{aplay -L}}} for playback, or
{{{arecord -L}}} for record) (ie {{{sysdefault:CARD=sgtl5000audio}}}) or the hw:x,y
notation (ie {{{hw:0,0}}} for first device, first subdevice)
If not specified via the {{{device}}} property, the device used for alsasrc and
alsasink will depend on {{{/etc/asound.conf}}} and/or {{{~/.asoundrc}}}.
Playback and Capture also depends on your ALSA mixer ({{{amixer}}}) settings. See
[wiki:ventana/audio#Mixermuxgainvolume mixer settings] for more info.
[=#audio-output]
== Audio Output ==
Generally, a 'sink' plugin is one that will take an audio stream and send it to an
audio device. Please refer to [http://trac.gateworks.com/wiki/ventana/audio this
audio] page for more details on audio devices on the ventana platform.
[=#audio-input]
== Audio Input ==
An input source is anything coming from a capture device on the SBC, e.g. HDMI
audio in/analog audio in. Please refer to
[http://trac.gateworks.com/wiki/ventana/audio this audio] page for more details on
audio devices on the ventana platform.
[=#audio-encoding]
== Encoding ==
Encoding is the term used to capture audio and encode it to a new format type.
There are many more. You can search for your specified one by running a similar
search: {{{gst-inspect-1.0 | grep enc}}}.
[=#audio-decoding]
== Decoding ==
Decoding is the term used to decode an encoded audio stream to a raw audio stream.
[=#audio-format]
== Audio Format Conversion ==
In specify the details of the audio format, you use a GStreamer {{{capsfilter}}}
and to convert it from one format to another you use the GStreamer
{{{audioconvert}}} element.
{{{#!bash
gst-launch-1.0 alsasrc device="hw:0,0" ! "audio/x-
raw,rate=32000,channels=2,depth=16" ! \
audioconvert ! avimux ! filesink location=./audio.avi
}}}
[=#audio-loopback]
== Audio loopback (Useful for testing audio input and output) ==
A simple aduio loopback test can take audio input from an input device and output
it to an output device.
To send audio from the sgtl5000 (analog input) to the imxhdmisoc (HDMI output):
* using device/function numbers (ie from {{{aplay -l}}}):
{{{#!bash
gst-launch-1.0 alsasrc device="hw:0,0" ! alsasink device="hw:2,0"
}}}
* or, using names (ie from {{{aplay -L}}}):
{{{#!bash
gst-launch-1.0 alsasrc device="sysdefault:CARD=sgtl5000audio" ! \
alsasink device="sysdefault:CARD=imxhdmisoc"
}}}
To send audio from the tda1997x HDMI receiver (digital input) to the imxhdmisoc
(digital output):
{{{#!bash
gst-launch-1.0 alsasrc device="sysdefault:CARD=tda1997xaudio" ! \
"audio/x-raw,rate=44100" ! alsasink device="sysdefault:CARD=imxhdmisoc"
}}}
* Note here we need to specify the audio sample-rate as it can vary per input
stream (and gstreamer does not validate the rate). This rate must match the source
stream samplrate which can be found via sysfs {{{/sys/bus/i2c/drivers/tda1997x/2-
0048/audmode}}}. If your output device requires a different sample-rate than the
source input device, you need to perform a sample-rate conversion.