audiorate

This element takes an incoming stream of timestamped raw audio frames and produces a perfect stream by inserting or dropping samples as needed.

This operation may be of use to link to elements that require or otherwise implicitly assume a perfect stream as they do not store timestamps, but derive this by some means (e.g. bitrate for some AVI cases).

The properties in, out, add and drop can be read to obtain information about number of input samples, output samples, dropped samples (i.e. the number of unused input samples) and inserted samples (i.e. the number of samples added to stream).

When the silent property is set to FALSE, a GObject property notification will be emitted whenever one of the add or drop values changes. This can potentially cause performance degradation. Note that property notification will happen from the streaming thread, so applications should be prepared for this.

If the tolerance property is non-zero, and an incoming buffer's timestamp deviates less than the property indicates from what would make a 'perfect time', then no samples will be added or dropped. Note that the output is still guaranteed to be a perfect stream, which means that the incoming data is then simply shifted (by less than the indicated tolerance) to a perfect time.

Example pipelines

 gst-launch-1.0 -v autoaudiosrc ! audiorate ! audioconvert ! wavenc ! filesink location=alsa.wav

Capture audio from the sound card and turn it into a perfect stream for saving in a raw audio file.

 gst-launch-1.0 -v uridecodebin uri=file:///path/to/audio.file ! audiorate ! audioconvert ! wavenc ! filesink location=alsa.wav

Decodes an audio file and transforms it into a perfect stream for saving in a raw audio WAV file. Without the audio rate, the timing might not be preserved correctly in the WAV file in case the decoded stream is jittery or there are samples missing.

Hierarchy

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstElement
                ╰──audiorate

Factory details

Authors: – Wim Taymans

Classification:Filter/Effect/Audio

Rank – none

Plugin – audiorate

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 }

Presencealways

Directionsink

Object typeGstPad


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 }

Presencealways

Directionsrc

Object typeGstPad


Properties

add

“add” guint64

Number of added samples

Flags : Read

Default value : 0


drop

“drop” guint64

Number of dropped samples

Flags : Read

Default value : 0


in

“in” guint64

Number of input samples

Flags : Read

Default value : 0


out

“out” guint64

Number of output samples

Flags : Read

Default value : 0


silent

“silent” gboolean

Don't emit notify for dropped and duplicated frames

Flags : Read / Write

Default value : true


skip-to-first

“skip-to-first” gboolean

Don't produce buffers before the first one we receive.

Flags : Read / Write

Default value : false


tolerance

“tolerance” guint64

The difference between incoming timestamp and next timestamp must exceed the given value for audiorate to add or drop samples.

Flags : Read / Write

Default value : 40000000


The results of the search are