GStreamer - ArchWiki

Jump to content

# GStreamer

From ArchWiki

From Wikipedia:

  GStreamer is a pipeline-based multimedia framework that links together a wide variety of media processing systems to complete complex workflows. For instance, GStreamer can be used to build a system that reads files in one format, processes them, and exports them in another. The formats and processes can be changed in a plug and play fashion.
  GStreamer supports a wide variety of media-handling components, including simple audio playback, audio and video playback, recording, streaming and editing. The pipeline design serves as a base to create many types of multimedia applications such as video editors, transcoders, streaming media broadcasters and media players.

## Installation

Install the gstreamer package.

To make GStreamer useful, install the plugins packages you require. See official documentation for list of features in each plugin.

- gst-libav - Libav-based plugin containing many decoders and encoders.
- gst-plugins-bad - Plugins that need more quality, testing or documentation.
- gst-plugins-base - Essential exemplary set of elements.
- gst-plugins-good - Good-quality plugins under LGPL license.
- gst-plugins-ugly - Good-quality plugins that might pose distribution problems.

## Usage

### Using gst-launch-1.0

A helpful tool of GStreamer is the gst-launch-1.0(1) command. It is an extremely versatile command line tool to create GStreamer pipelines. It is very similar to and can do many of the things the FFmpeg command can do. Here are some examples:

Convert an MP4 file to MKV:

    $ gst-launch-1.0 filesrc location=source.mp4 ! qtdemux name=demux matroskamux name=mux ! filesink location=dest.mkv  demux.audio_0 ! queue ! aacparse ! queue ! mux.audio_0  demux.video_0 ! queue ! h264parse ! queue ! mux.video_0

### Using gst-discoverer-1.0

Another helpful tool is gst-discoverer-1.0(1), which is the GStreamer equivalent of FFmpeg's ffprobe(1).

Get info on a video file:

    $ gst-discoverer-1.0 file.mp4

    Properties:
      Duration: 0:02:55.613000000
      Seekable: yes
      Live: no
      container: Quicktime
        audio: MPEG-4 AAC
          Stream ID: c910ef2fa357f9f4ad365aebc98cfca88d23fdca99d832645f5113efa43b0cd3/002
          Language: <unknown>
          Channels: 2 (front-left, front-right)
          Sample rate: 44100
          Depth: 16
          Bitrate: 125588
          Max bitrate: 125588
        video: H.264 (Constrained Baseline Profile)
          Stream ID: c910ef2fa357f9f4ad365aebc98cfca88d23fdca99d832645f5113efa43b0cd3/001
          Width: 192
          Height: 144
          Depth: 24
          Frame rate: 15000/1001
          Pixel aspect ratio: 1/1
          Interlaced: false
          Bitrate: 107884
          Max bitrate: 107884

## Integration

### PulseAudio

PulseAudio support is provided by the gst-plugins-good package.

### PipeWire

PipeWire support is provided by the gst-plugin-pipewire package.

### KDE / Phonon integration

See Phonon.

### Hardware video acceleration

See Hardware video acceleration.

GStreamer will automatically detect and use the correct API [1]. Depending on the system install:

- gst-plugin-va for VA-API support.
- gst-plugins-bad and nvidia-utils for NVDECODE/NVENCODE support.

If the new elements do not show up after installing the packages, you may want to delete and rebuild the plugin registry. Usually it suffices to

    $ rm ~/.cache/gstreamer-1.0/registry.*.bin

Gstreamer will then rebuild the registry on the next invocation, which usually takes a few seconds.

#### Verify VA-API support

To verify VA-API support:

    $ gst-inspect-1.0 va

    Plugin Details:
      Name                     va
      Description              VA-API codecs plugin
      Filename                 /usr/lib/gstreamer-1.0/libgstva.so
      Version                  version
      License                  LGPL
      Source module            gst-plugins-bad
      Documentation            https://gstreamer.freedesktop.org/documentation/va/
      Source release date      date
      Binary package           Arch Linux gst-plugins-bad version
      Origin URL               https://archlinux.org/

      vaav1dec: VA-API AV1 Decoder
      vacompositor: VA-API Video Compositor
      vadeinterlace: VA-API Deinterlacer
      vah264dec: VA-API H.264 Decoder
      vah264enc: VA-API H.264 Encoder
      vah264lpenc: VA-API H.264 Low Power Encoder
      vah265dec: VA-API H.265 Decoder
      vah265enc: VA-API H.265 Encoder
      vah265lpenc: VA-API H.265 Low Power Encoder
      vajpegdec: VA-API JPEG Decoder
      vampeg2dec: VA-API Mpeg2 Decoder
      vapostproc: VA-API Video Postprocessor
      vavp8dec: VA-API VP8 Decoder
      vavp9dec: VA-API VP9 Decoder

      14 features:
      +-- 14 elements

#### Verify NVDECODE/NVENCODE support

To verify NVDECODE/NVENCODE support:

    $ gst-inspect-1.0 nvcodec

    Plugin Details:
      Name                     nvcodec
      Description              GStreamer NVCODEC plugin
      Filename                 /usr/lib/gstreamer-1.0/libgstnvcodec.so
      Version                  version
      License                  LGPL
      Source module            gst-plugins-bad
      Source release date      date
      Binary package           GStreamer Bad Plugins (Arch Linux)
      Origin URL               https://archlinux.org/

      cudadownload: CUDA downloader
      cudaupload: CUDA uploader
      nvautogpuh264enc: NVENC H.264 Video Encoder Auto GPU select Mode
      nvautogpuh265enc: NVENC H.265 Video Encoder Auto GPU select Mode
      nvav1dec: NVDEC AV1 Decoder
      nvcudah264enc: NVENC H.264 Video Encoder CUDA Mode
      nvcudah265enc: NVENC H.265 Video Encoder CUDA Mode
      nvh264dec: NVDEC h264 Video Decoder
      nvh264enc: NVENC H.264 Video Encoder
      nvh264sldec: NVDEC H.264 Stateless Decoder
      nvh265dec: NVDEC h265 Video Decoder
      nvh265enc: NVENC HEVC Video Encoder
      nvh265sldec: NVDEC H.265 Stateless Decoder
      nvjpegdec: NVDEC jpeg Video Decoder
      nvmpeg2videodec: NVDEC mpeg2video Video Decoder
      nvmpeg4videodec: NVDEC mpeg4video Video Decoder
      nvmpegvideodec: NVDEC mpegvideo Video Decoder
      nvvp8dec: NVDEC vp8 Video Decoder
      nvvp8sldec: NVDEC VP8 Stateless Decoder
      nvvp9dec: NVDEC vp9 Video Decoder
      nvvp9sldec: NVDEC VP9 Stateless Decoder

      21 features:
      +-- 21 elements

#### Set decoder ranks

For some NVIDIA users, gst-libav may prioritize the Libav decoder over nvcodec decoders which will inhibit hardware acceleration. The `GST_PLUGIN_FEATURE_RANK` environment variable can be used to rank decoders and thus alleviate this issue. See "GST_PLUGIN_FEATURE_RANK" in the documentation for more information. For example:

    GST_PLUGIN_FEATURE_RANK=nvmpegvideodec:MAX,nvmpeg2videodec:MAX,nvmpeg4videodec:MAX,nvh264sldec:MAX,nvh264dec:MAX,nvjpegdec:MAX,nvh265sldec:MAX,nvh265dec:MAX,nvvp9dec:MAX

Those without AV1 hardware support may also want to disable AV1 decoders (e.g., for YouTube on webkit2gtk-based browsers) by appending `avdec_av1:NONE` and `av1dec:NONE` to the list above.

## See also

- Sound system
- website

Category:

- Multimedia

GStreamer
Add topic