Gstreamer 用户使用指南
Revision History
Revision | Date | Author | Description |
---|---|---|---|
1.0 | 2025-1-10 | lizhirong | Initial draft |
GStreamer 介绍
GStreamer 是一个开源的多媒体框架。该框架基于插件进行设计,所有的插件都能够被链接到任意的已经定义了的数据流管道中。
官方网址:https://gstreamer.freedesktop.org
GStreamer 框架
gstreamer 可以通过创建一系列的元件(element),并把它们连接起来,从而让数据流在这个被连接的各个元件(element)之间传输,从而创建一个管道(pipeline)来完成一个特殊的任务,例如:媒体播放或者录音。
gstreamer 框架如下图所示:
Gstreamer 源码分布结构
Gstreamer 将其各个模块根据功能分为了多个 repo 分别存放。其框架和基本库分别被方在 gstreamer 和 gst-plugins-base 这两个 repo 中,其他的 repo 存放各种插件,并只依赖于这两个 repo,互相之间没有依赖。其中 gst-plugins-good 主要包含比较成熟的插件,gst-plugins-bad 则主要包含正在开发的插件,gst-plugins-ugly 不是指 code 质量差,而是主要放置了一些有 license 问题的插件,用户可以根据地域和法规,进行选择性的规避或安装。
仓库 | 功能 |
---|---|
gstreamer | 框架和基本库 |
gst-plugins-base | 框架和基本库 |
gst-plugins-good | 比较成熟的插件 |
gst-plugins-bad | 包含正在开发的插件,可能存在问题 |
gst-plugins-ugly | 有license问题的插件,用户可以根据地域和法规,进行选择性的规避或安装 |
gst-libav | libav 编解码库的插件 |
Gstreamer 安装
安装 Gstreamer-1.0 需运行命令:
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
检查 Gstramer-1.0 的版本,需执行命令:
gst-inspect-1.0 --version
Gstreamer 插件说明
使用以下命令可以用于查询当前 bianbu os/bianbu linux 系统 Gstreamer 默认支持的插件情况
gst-inspect-1.0
在gst-inspect-1.0命令后加上插件名称,可以输出对应插件的详细信息。
Video Decoder Plugins
视频解码器的作用是将视频源格式转换为可以被目标接收器(例如显示器)解释的原始格式。Spacemit GStreamer 支持 spacemitdec 专有插件,该插件可以帮助用户获得更优质的结果。
Video Decoder | Package | Description | Bianbu OS(Y/N) | Bianbu Linux(Y/N) |
---|---|---|---|---|
decodebin | gst-plugins-base | Autoplug and decode to raw media | Y | Y |
spacemitdec | gst-plugins-bad | Decodes H264/H265/MJPEG/VP8/VP9/MPEG2/MPEG4 via MPP API | Y | Y |
avdec_xxxx | gstreamer1.0-libav | ffmpeg plugin for GStreamer | Y | Y |
mpeg2dec | gst-plugins-ugly | mpeg1 and mpeg2 video decoder | Y | N |
openh264dec | gst-plugins-bad | OpenH264 video decoder | Y | N |
jpegdec | gst-plugins-good | Decode images from JPEG format | Y | N |
vp8dec | gst-plugins-good | On2 VP8 Decoder | Y | N |
vp9dec | gst-plugins-good | On2 VP9 Decoder | Y | N |
Video Encoder Plugins
视频编码器的作用是将原始数据转换为编码的视频格式,例如 H.264 格式。Spacemit GStreamer 支持 spacemit*enc 专有插件,这些插件可以帮助用户获得更优质的结果。
Video Encoder | Package | Description | Bianbu OS(Y/N) | Bianbu Linux(Y/N) |
---|---|---|---|---|
encodebin | gst-plugins-base | Convenience encoding/muxing element | Y | N |
spacemith264enc | gst-plugins-bad | Encodes H264 via MPP API | Y | Y |
spacemith265enc | gst-plugins-bad | Encodes H265 via MPP API | Y | Y |
spacemitmjpegenc | gst-plugins-bad | Encodes MJPEG via MPP API | Y | Y |
spacemitmpegenc | gst-plugins-bad | Encodes MPEG2/MPEG4 via MPP API | Y | Y |
spacemitvp8enc | gst-plugins-bad | Encodes vp8 via MPP API | Y | Y |
spacemitvp9enc | gst-plugins-bad | Encodes vp9 via MPP API | Y | Y |
avenc_xxxx | gstreamer1.0-libav | ffmpeg plugin for GStreamer | Y | Y |
mpeg2enc | gst-plugins-ugly | mpeg2enc video encoder | Y | N |
openh264enc | gst-plugins-bad | OpenH264 video encoder | Y | N |
jpegenc | gst-plugins-good | JPEG image encoder | Y | N |
vp8enc | gst-plugins-good | On2 VP8 Encoder | Y | N |
vp9enc | gst-plugins-good | On2 VP9 Encoder | Y | N |
Video Sink Plugins
视频接收插件的作用是将处理后的数据通过显示输出进行展示。Spacemit GStreamer 优化了 glimagesink/gtkglsink/waylandsink 插件,这些插件可以帮助用户获得更优质的结果。
Video Encoder | Package | Description | Bianbu OS(Y/N) | Bianbu Linux(Y/N) |
---|---|---|---|---|
autovideosink | gst-plugins-good | Wrapper video sink for automatically detected videosink | Y | Y |
glimagesink | gst-plugins-base | Infrastructure to process GL textures | Y | N |
waylandsink | gst-plugins-bad | Output to wayland surface | Y | Y |
gtkglsink | gst-plugins-good | A video sink that renders to a GtkWidget using OpenGL | Y | N |
fpsdisplaysink | gst-plugins-bad | Video sink with current and average framerate | Y | N |
Demux Plugins
解复用器插件的作用是将不同的视频/音频格式转换为原始的。
Video Demux | Package | Description | Bianbu OS(Y/N) | Bianbu Linux(Y/N) |
---|---|---|---|---|
qtdemux | gst-plugins-good | Demux a .mov/.mp4 file to raw data | Y | Y |
matroskedemux | gst-plugins-good | Demux a .mkv file to raw data | Y | N |
flvdemux | gst-plugins-good | Demux a .flv file to raw data | Y | N |
avidemux | gst-plugins-good | Demux a .avi file to raw data | Y | Y |
Mux Plugins
复用器插件负责将原始未解析的数据转换为特定的视频/音频数据。
Video Mux | Package | Description | Bianbu OS(Y/N) | Bianbu Linux(Y/N) |
---|---|---|---|---|
qtmux | gst-plugins-good | Mux a raw data to a .mov file | Y | Y |
matroskemux | gst-plugins-good | Mux a raw data to a .mkv file | Y | N |
flvmux | gst-plugins-good | Mux a raw data to a .flv file | Y | N |
avimux | gst-plugins-good | Mux a raw data to a .avi file | Y | Y |
mp4mux | gst-plugins-good | Mux a raw data to a .mp4 file | Y | Y |
Audio Plugins
音频插件的作用是处理来自音频原始格式或特定音频数据格式(如 WAV)的数据。
Audio Plugin | Package | Description | Bianbu OS(Y/N) | Bianbu Linux(Y/N) |
---|---|---|---|---|
mpg123audiodec | gst-plugins-good | MP3 decoding plugin based on the mpg123 library | Y | N |
vorbisdec | gst-plugins-base | Decodes raw vorbis streams to float audio | Y | N |
vorbisenc | gst-plugins-base | Encodes audio in Vorbis format | Y | N |
alsasink | gst-plugins-base | Output to a sound card via ALSA | Y | N |
pulsesink | gst-plugins-good | Plays audio to a PulseAudio server | Y | N |
Image Plugins
图像插件的作用是处理来自图像原始格式或特定数据格式(如 JPEG)的数据。
Image Plugin | Package | Description | Bianbu OS(Y/N) | Bianbu Linux(Y/N) |
---|---|---|---|---|
spacemitdec | gst-plugins-bad | Decodes H264/H265/MJPEG/VP8/VP9/MPEG2/MPEG4 via MPP API | Y | Y |
spacemitmjpegenc | gst-plugins-bad | Encodes MJPEG via MPP API | Y | Y |
imagefreeze | gst-plugins-good | Generates a still frame stream from an image | Y | N |
jpegdec | gst-plugins-good | Decode images from JPEG format | Y | N |
jpegenc | gst-plugins-good | JPEG image encoder | Y | N |
pngdec | gst-plugins-good | Decode a png video frame to a raw image | Y | N |
pngenc | gst-plugins-good | Encode a video frame to a .png image | Y | N |
Network Protocol Plugins
网络协议插件的作用是负责在设备之间建立网络连接。
Network Plugins | Package | Description | Bianbu OS(Y/N) | Bianbu Linux(Y/N) |
---|---|---|---|---|
udpsink | gst-plugins-good | Send data over the network via UDP | Y | Y |
multiudpsink | gst-plugins-good | Send data over the network via UDP to one or multiple recipients | Y | Y |
udpsrc | gst-plugins-good | Receive data over the network via UDP | Y | Y |
tcpserversink | gst-plugins-base | Send data as a server over the network via TCP | Y | N |
tcpclientsrc | gst-plugins-base | Receive data as a client over the network via TCP | Y | N |
rtspsrc | gst-plugins-good | Receive data over the network via RTSP | Y | N |
Payload/Depayload Plugins
有效载荷插件负责在网络上传输数据,而去有效载荷插件则与这些插件结合使用,以接收和解包 数据。
Network Plugins | Package | Description | Bianbu OS(Y/N) | Bianbu Linux(Y/N) |
---|---|---|---|---|
gdppay | gst-plugins-bad | Payloads GStreamer Data Protocol buffers | Y | N |
gdpdepay | gst-plugins-bad | Depayloads GStreamer Data Protocol buffers | Y | N |
rtpvrawpay | gst-plugins-good | Payload raw video as RTP packets | Y | Y |
rtpvrawdepay | gst-plugins-good | Extracts raw video as RTP packets | Y | Y |
rtph264pay | gst-plugins-good | Payload-encode H264 video into RTP packets | Y | Y |
rtph264depay | gst-plugins-good | Extracts H264 video from RTP packets | Y | Y |
rtpmpapay | gst-plugins-good | Payload MPEG audio as RTP packets | Y | Y |
rtpmpadepay | gst-plugins-good | Extracts MPEG audio from RTP packets | Y | Y |
rtpjitterbuffer | gst-plugins-good | A buffer that deals with network jitter and other transmission faults | Y | Y |
Gstreamer 基本命令
gst-launch-1.0
gst-launch-1.0:用于启动一个流水线来完成一个特殊的任务,例如:媒体播放或者录音等。下面是一些常用的使用示例(以 spacemit 已适配的 gstreamer 插件为主):