audioconvert
Audioconvert converts raw audio buffers between various possible formats. It supports integer to float conversion, width/depth conversion, signedness and endianness conversion and channel transformations (ie. upmixing and downmixing), as well as dithering and noise-shaping.
Example launch line
gst-launch-1.0 -v -m audiotestsrc ! audioconvert ! audio/x-raw,format=S8,channels=2 ! level ! fakesink silent=TRUE
This pipeline converts audio to 8-bit. The level element shows that the output levels still match the one for a sine wave.
gst-launch-1.0 -v -m uridecodebin uri=file:///path/to/audio.flac ! audioconvert ! vorbisenc ! oggmux ! filesink location=audio.ogg
The vorbis encoder takes float audio data instead of the integer data output by most other audio elements. This pipeline decodes a FLAC audio file (or any other audio file for which decoders are installed) and re-encodes it into an Ogg/Vorbis audio file.
A mix matrix can be passed to audioconvert, that will govern the remapping of input to output channels.
Example matrix generation code
To generate the matrix using code:
GValue v = G_VALUE_INIT;
GValue v2 = G_VALUE_INIT;
GValue v3 = G_VALUE_INIT;
g_value_init (&v2, GST_TYPE_ARRAY);
g_value_init (&v3, G_TYPE_FLOAT);
g_value_set_float (&v3, 1);
gst_value_array_append_value (&v2, &v3);
g_value_unset (&v3);
[ Repeat for as many float as your input channels - unset and reinit v3 ]
g_value_init (&v, GST_TYPE_ARRAY);
gst_value_array_append_value (&v, &v2);
g_value_unset (&v2);
[ Repeat for as many v2's as your output channels - unset and reinit v2]
g_object_set_property (G_OBJECT (audioconvert), "mix-matrix", &v);
g_value_unset (&v);
Example launch line
gst-launch-1.0 audiotestsrc ! audio/x-raw, channels=4 ! audioconvert mix-matrix="<<1.0, 0.0, 0.0, 0.0>, <0.0, 1.0, 0.0, 0.0>>" ! audio/x-raw,channels=2 ! autoaudiosink
If an empty mix matrix is specified, a (potentially truncated) identity matrix will be generated.
Example empty matrix generation code
GValue v = G_VALUE_INIT;
g_value_init (&v, GST_TYPE_ARRAY);
g_object_set_property (G_OBJECT (audioconvert), "mix-matrix", &v);
g_value_unset (&v);
Example empty matrix launch line
gst-launch-1.0 -v audiotestsrc ! audio/x-raw,channels=8 ! audioconvert mix-matrix="<>" ! audio/x-raw,channels=16,channel-mask=\(bitmask\)0x0000000000000000 ! fakesink
Hierarchy
GObject ╰──GInitiallyUnowned ╰──GstObject ╰──GstElement ╰──GstBaseTransform ╰──audioconvert
Factory details
Authors: – Benjamin Otte
Classification: – Filter/Converter/Audio
Rank – primary
Plugin – audioconvert
Package – GStreamer Base Plug-ins
Pad Templates
sink
audio/x-raw:
format: { F64LE, F64BE, F32LE, F32BE, S32LE, S32BE, U32LE, U32BE, S24_32LE, S24_32BE, U24_32LE, U24_32BE, S24LE, S24BE, U24LE, U24BE, S20LE, S20BE, U20LE, U20BE, S18LE, S18BE, U18LE, U18BE, S16LE, S16BE, U16LE, U16BE, S8, U8 }
rate: [ 1, 2147483647 ]
channels: [ 1, 2147483647 ]
layout: { (string)interleaved, (string)non-interleaved }
src
audio/x-raw:
format: { F64LE, F64BE, F32LE, F32BE, S32LE, S32BE, U32LE, U32BE, S24_32LE, S24_32BE, U24_32LE, U24_32BE, S24LE, S24BE, U24LE, U24BE, S20LE, S20BE, U20LE, U20BE, S18LE, S18BE, U18LE, U18BE, S16LE, S16BE, U16LE, U16BE, S8, U8 }
rate: [ 1, 2147483647 ]
channels: [ 1, 2147483647 ]
layout: { (string)interleaved, (string)non-interleaved }
Properties
dithering
“dithering” GstAudioDitherMethod *
Selects between different dithering methods.
Flags : Read / Write
Default value : tpdf (2)
mix-matrix
“mix-matrix” GstValueArray *
Transformation matrix for input/output channels
Flags : Read / Write
noise-shaping
“noise-shaping” GstAudioNoiseShapingMethod *
Selects between different noise shaping methods.
Flags : Read / Write
Default value : none (0)
The results of the search are