GStreamer Audio Codec Use
Introduction
The GStreamer supports a lot of audio codecs in its plugin, it only needs to check the corresponding option in make menuconfig, and it will download the dependent third-party codec packages when compiling.
This document will describe where some common audio codecs are located in GStreamer and how to use them with the GStreamer command line.
Before testing the codec, you need to prepare a real audio file as a way to determine if the encoding is correct. Here is provide a WAV file for testing:
Codec
AAC
AAC(Advanced Audio Coding) is a lossy file compression format designed for sound data and based on the MPEG-2 audio coding technology. It appears to instead MP3.
The GStreamer supports more than one AAC encoder, and different encoders differ in efficiency and accuracy. From the test result, the combined quality is fdk-aac > aac > vo-aacenc.
voaacenc
Test input from a fake source
gst-launch-1.0 -v audiotestsrc ! voaacenc ! audio/mpeg,stream-format=adts ! filesink location=encvo.aac
Test input from the test file
gst-launch-1.0 filesrc location=tech_news.wav ! wavparse ! audioresample ! audioconvert ! voaacenc ! audio/mpeg,stream-format=adts ! filesink location=tencvo.aac
fdkaacenc
Test input from a fake source
gst-launch-1.0 -v audiotestsrc ! fdkaacenc ! audio/mpeg,stream-format=adts ! filesink location=encfdk.aac
Test input from the test file
avenc_aac/avmux_adts
Test input from a fake source
Test input from the test file
Opus + Ogg
Opus is a lossy sound encoding format. It emerged from the desire to contain sound and voice in a single format, replacing Speex and Vorbis, and is suitable for low-latency instant sound transmission over the network.
Ogg (OGGVorbis) is an audio compression format, similar to music formats such as MP3, etc. Ogg is completely free, open, and patent-free.
Since the Opus file can not be played directly on the PC, we encode Opus data with Ogg to easy to play.
Here the Opus encoder and Ogg muxer support in the GStreamer is based on the library opus and libogg.
opusenc
oggmux
Test input from a fake source
Test input from the test file
Mp3
MP3(Moving Picture Experts Group Audio Layer III) is an audio compression technique. It is designed to drastically reduce the amount of audio data.
The GStreamer supports MP3 encoder is lame.
lamemp3enc
Test input from a fake source
Test input from the test file
Wav
WAV is one of the most common sound file formats, it can record a variety of mono or stereo sound information, and can ensure that the sound is not distorted. Due to its large file size, it is mostly used to store short sound clips.
wavenc
Test input from a fake source
Test input from the test file
avmux_wav
Test input from a fake source
Test input from the test file
G722
G.722, also known as ITU-T G.722, is the first broadband speech coding algorithm for 16KHz sampling rate, which was finalized by the International Telecommunication Union (ITU-T) in 1988.
avenc_g722
Test input from a fake source
Here just introduce and test some common audio coding formats, and other codecs such as adpcm, ac3, flac, and sbc, please consult the official documentation of GSteamer.