Skip to main content

Gstreamer User Guide

| ----------------- | ------------------ | --------------- | ---------------------- | | 1.0 | 2025-1-10 | lizhirong | Initial draft |

GStreamer Introduction

GStreamer is an open-source multimedia framework. The framework is designed based on plugins, and all plugins can be linked into any predefined data stream pipeline.

Official website: https://gstreamer.freedesktop.org

GStreamer Framework

GStreamer can create a series of elements and connect them to allow data streams to be transmitted between these connected elements, thereby creating a pipeline to complete a specific task, such as media playback or recording.

The GStreamer framework is shown in the figure below:

Gstreamer Source Code Distribution Structure

Gstreamer divides its various modules into multiple repositories based on functionality. The framework and basic libraries are stored in the gstreamer and gst-plugins-base repositories, while other repositories store various plugins and only depend on these two repositories without interdependencies. The gst-plugins-good repository mainly contains mature plugins, gst-plugins-bad mainly contains plugins under development, and gst-plugins-ugly contains plugins with licensing issues. Users can selectively avoid or install them based on region and regulations.

RepositoryFunction
gstreamerFramework and basic libraries
gst-plugins-baseFramework and basic libraries
gst-plugins-goodMature plugins
gst-plugins-badPlugins under development, may have issues
gst-plugins-uglyPlugins with licensing issues, users can selectively avoid or install based on region and regulations
gst-libavPlugins for libav codec library

Gstreamer Installation

To install Gstreamer-1.0, run the command:

sudo apt-get update

sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav

sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev

To check the version of Gstreamer-1.0, execute the command:

gst-inspect-1.0 --version  

Gstreamer Plugin Description

Use the following command to query the default supported plugins of Gstreamer in the bianbu os/bianbu linux system

gst-inspect-1.0

Adding the plugin name after the gst-inspect-1.0 command will output detailed information about the corresponding plugin.

Video Decoder Plugins

The role of video decoders is to convert the video source format into a raw format that can be interpreted by the target receiver (e.g., display). Spacemit GStreamer supports the proprietary spacemitdec plugin, which can help users achieve better results.

Video DecoderPackageDescriptionBianbu OS(Y/N)Bianbu Linux(Y/N)
decodebingst-plugins-baseAutoplug and decode to raw mediaYY
spacemitdecgst-plugins-badDecodes H264/H265/MJPEG/VP8/VP9/MPEG2/MPEG4 via MPP APIYY
avdec_xxxxgstreamer1.0-libavffmpeg plugin for GStreamerYY
mpeg2decgst-plugins-uglympeg1 and mpeg2 video decoderYN
openh264decgst-plugins-badOpenH264 video decoderYN
jpegdecgst-plugins-goodDecode images from JPEG formatYN
vp8decgst-plugins-goodOn2 VP8 DecoderYN
vp9decgst-plugins-goodOn2 VP9 DecoderYN

Video Encoder Plugins

The role of video encoders is to convert raw data into encoded video formats, such as H.264 format. Spacemit GStreamer supports proprietary spacemit*enc plugins, which can help users achieve better results.

Video EncoderPackageDescriptionBianbu OS(Y/N)Bianbu Linux(Y/N)
encodebingst-plugins-baseConvenience encoding/muxing elementYN
spacemith264encgst-plugins-badEncodes H264 via MPP APIYY
spacemith265encgst-plugins-badEncodes H265 via MPP APIYY
spacemitmjpegencgst-plugins-badEncodes MJPEG via MPP APIYY
spacemitmpegencgst-plugins-badEncodes MPEG2/MPEG4 via MPP APIYY
spacemitvp8encgst-plugins-badEncodes vp8 via MPP APIYY
spacemitvp9encgst-plugins-badEncodes vp9 via MPP APIYY
avenc_xxxxgstreamer1.0-libavffmpeg plugin for GStreamerYY
mpeg2encgst-plugins-uglympeg2enc video encoderYN
openh264encgst-plugins-badOpenH264 video encoderYN
jpegencgst-plugins-goodJPEG image encoderYN
vp8encgst-plugins-goodOn2 VP8 EncoderYN
vp9encgst-plugins-goodOn2 VP9 EncoderYN

Video Sink Plugins

The role of video sink plugins is to display the processed data through display output. Spacemit GStreamer optimizes the glimagesink/gtkglsink/waylandsink plugins, which can help users achieve better results.

Video EncoderPackageDescriptionBianbu OS(Y/N)Bianbu Linux(Y/N)
autovideosinkgst-plugins-goodWrapper video sink for automatically detected videosinkYY
glimagesinkgst-plugins-baseInfrastructure to process GL texturesYN
waylandsinkgst-plugins-badOutput to wayland surfaceYY
gtkglsinkgst-plugins-goodA video sink that renders to a GtkWidget using OpenGLYN
fpsdisplaysinkgst-plugins-badVideo sink with current and average framerateYN

Demux Plugins

The role of demuxer plugins is to convert different video/audio formats into raw data.

Video DemuxPackageDescriptionBianbu OS(Y/N)Bianbu Linux(Y/N)
qtdemuxgst-plugins-goodDemux a .mov/.mp4 file to raw dataYY
matroskedemuxgst-plugins-goodDemux a .mkv file to raw dataYN
flvdemuxgst-plugins-goodDemux a .flv file to raw dataYN
avidemuxgst-plugins-goodDemux a .avi file to raw dataYY

Mux Plugins

The role of muxer plugins is to convert raw unparsed data into specific video/audio data.

Video MuxPackageDescriptionBianbu OS(Y/N)Bianbu Linux(Y/N)
qtmuxgst-plugins-goodMux raw data to a .mov fileYY
matroskemuxgst-plugins-goodMux raw data to a .mkv fileYN
flvmuxgst-plugins-goodMux raw data to a .flv fileYN
avimuxgst-plugins-goodMux raw data to a .avi fileYY
mp4muxgst-plugins-goodMux raw data to a .mp4 fileYY

Audio Plugins

The role of audio plugins is to process data from raw audio formats or specific audio data formats (e.g., WAV).

Audio PluginPackageDescriptionBianbu OS(Y/N)Bianbu Linux(Y/N)
mpg123audiodecgst-plugins-goodMP3 decoding plugin based on the mpg123 libraryYN
vorbisdecgst-plugins-baseDecodes raw vorbis streams to float audioYN
vorbisencgst-plugins-baseEncodes audio in Vorbis formatYN
alsasinkgst-plugins-baseOutput to a sound card via ALSAYN
pulsesinkgst-plugins-goodPlays audio to a PulseAudio serverYN

Image Plugins

The role of image plugins is to process data from raw image formats or specific data formats (e.g., JPEG).

Image PluginPackageDescriptionBianbu OS(Y/N)Bianbu Linux(Y/N)
spacemitdecgst-plugins-badDecodes H264/H265/MJPEG/VP8/VP9/MPEG2/MPEG4 via MPP APIYY
spacemitmjpegencgst-plugins-badEncodes MJPEG via MPP APIYY
imagefreezegst-plugins-goodGenerates a still frame stream from an imageYN
jpegdecgst-plugins-goodDecode images from JPEG formatYN
jpegencgst-plugins-goodJPEG image encoderYN
pngdecgst-plugins-goodDecode a png video frame to a raw imageYN
pngencgst-plugins-goodEncode a video frame to a .png imageYN

Network Protocol Plugins

The role of network protocol plugins is to establish network connections between devices.

Network PluginsPackageDescriptionBianbu OS(Y/N)Bianbu Linux(Y/N)
udpsinkgst-plugins-goodSend data over the network via UDPYY
multiudpsinkgst-plugins-goodSend data over the network via UDP to one or multiple recipientsYY
udpsrcgst-plugins-goodReceive data over the network via UDPYY
tcpserversinkgst-plugins-baseSend data as a server over the network via TCPYN
tcpclientsrcgst-plugins-baseReceive data as a client over the network via TCPYN
rtspsrcgst-plugins-goodReceive data over the network via RTSPYN

Payload/Depayload Plugins

Payload plugins are responsible for transmitting data over the network, while depayload plugins are used in conjunction with these plugins to receive and unpack data.

Network PluginsPackageDescriptionBianbu OS(Y/N)Bianbu Linux(Y/N)
gdppaygst-plugins-badPayloads GStreamer Data Protocol buffersYN
gdpdepaygst-plugins-badDepayloads GStreamer Data Protocol buffersYN
rtpvrawpaygst-plugins-goodPayload raw video as RTP packetsYY
rtpvrawdepaygst-plugins-goodExtracts raw video as RTP packetsYY
rtph264paygst-plugins-goodPayload-encode H264 video into RTP packetsYY
rtph264depaygst-plugins-goodExtracts H264 video from RTP packetsYY
rtpmpapaygst-plugins-goodPayload MPEG audio as RTP packetsYY
rtpmpadepaygst-plugins-goodExtracts MPEG audio from RTP packetsYY
rtpjitterbuffergst-plugins-goodA buffer that deals with network jitter and other transmission faultsYY

Gstreamer Basic Commands

gst-launch-1.0

gst-launch-1.0: Used to start a pipeline to complete a specific task, such as media playback or recording. Below are some common usage examples (mainly using spacemit adapted gstreamer plugins):

Camera Application Scenarios

UVC Camera
  • UVC camera information can be obtained using the following command:
$ gst-device-monitor-1.0
Device found:

name : UvcH264 HD Pro Webcam C920
class : Video/CameraSource
caps : video/x-raw, format=YUY2, width=2304, height=1536, pixel-aspect-ratio=1/1, framerate=2/1
video/x-raw, format=YUY2, width=2304, height=1296, pixel-aspect-ratio=1/1, framerate=2/1
video/x-raw, format=YUY2, width=1920, height=1080, pixel-aspect-ratio=1/1, framerate=5/1
video/x-raw, format=YUY2, width=1600, height=896, pixel-aspect-ratio=1/1, framerate={ (fraction)15/2, (fraction)5/1 }
video/x-raw, format=YUY2, width=1280, height=720, pixel-aspect-ratio=1/1, framerate={ (fraction)10/1, (fraction)15/2, (fraction)5/1 }
video/x-raw, format=YUY2, width=960, height=720, pixel-aspect-ratio=1/1, framerate={ (fraction)15/1, (fraction)10/1, (fraction)15/2, (fraction)5/1 }
video/x-raw, format=YUY2, width=1024, height=576, pixel-aspect-ratio=1/1, framerate={ (fraction)15/1, (fraction)10/1, (fraction)15/2, (fraction)5/1 }
video/x-raw, format=YUY2, width=800, height=600, pixel-aspect-ratio=1/1, framerate={ (fraction)24/1, (fraction)20/1, (fraction)15/1, (fraction)10/1, (fraction)15/2, (fraction)5/1 }
video/x-raw, format=YUY2, width=864, height=480, pixel-aspect-ratio=1/1, framerate={ (fraction)24/1, (fraction)20/1, (fraction)15/1, (fraction)10/1, (fraction)15/2, (fraction)5/1 }
video/x-raw, format=YUY2, width=800, height=448, pixel-aspect-ratio=1/1, framerate={ (fraction)30/1, (fraction)24/1, (fraction)20/1, (fraction)15/1, (fraction)10/1, (fraction)15/2, (fraction)5/1 }
video/x-raw, format=YUY2, width=640, height=480, pixel-aspect-ratio=1/1, framerate={ (fraction)30/1, (fraction)24/1, (fraction)20/1, (fraction)15/1, (fraction)10/1, (fraction)15/2, (fraction)5/1 }
video/x-raw, format=YUY2, width=640, height=360, pixel-aspect-ratio=1/1, framerate={ (fraction)30/1, (fraction)24/1, (fraction)20/1, (fraction)15/1, (fraction)10/1, (fraction)15/2