> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GStreamer

> Push a live stream to Gcore Video Streaming with GStreamer using RTMP or SRT and H.264 AAC encoding.

GStreamer can push a live stream to Gcore Video Streaming over RTMP or SRT. Get the ingest URL and stream key from the Gcore Customer Portal, then run a `gst-launch-1.0` pipeline with H.264 video and AAC audio encoding.

## Setup

1. Install GStreamer and the required plugins. Download instructions are available on [gstreamer.freedesktop.org](https://gstreamer.freedesktop.org/download/).

   The pipelines below require the following plugin packages:

   * `gstreamer1.0-plugins-ugly` — provides `x264enc` for H.264 encoding
   * `gstreamer1.0-libav` — provides `avenc_aac` for AAC encoding
   * `gstreamer1.0-plugins-good` — provides `flvmux`, `rtpbin`, and other elements

2. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **Streaming** → **Live Streaming**, then open the live stream settings for the target stream. In the **URLs for encoder** section, select the protocol to use:
   * **RTMP** — copy the **Server** URL and **Stream Key**. Append the Stream Key to the Server URL to form the full ingest URL: `rtmp://vp-push-ed2.gvideo.co/in/{STREAM_ID}?{TOKEN}`
   * **SRT** — copy the full SRT URL. The URL format is `srt://vp-push-ed2-srt.gvideo.co:5001?streamid={STREAM_ID}#{TOKEN}`

## Pushing via RTMP

The pipeline below encodes a synthetic test source and sends it to the Gcore RTMP ingest endpoint:

```sh theme={null}
gst-launch-1.0 -v \
    videotestsrc is-live=true pattern=smpte ! \
        video/x-raw,format=I420,width=1920,height=1080,framerate=30/1 ! \
        x264enc tune=zerolatency bitrate=3000 speed-preset=veryfast key-int-max=60 bframes=0 ! \
        h264parse config-interval=1 ! queue ! mux. \
    audiotestsrc is-live=true wave=sine ! \
        audio/x-raw,channels=2,rate=48000 ! \
        avenc_aac bitrate=128000 ! queue ! mux. \
    flvmux name=mux streamable=true ! \
    rtmpsink location="rtmp://vp-push-ed2.gvideo.co/in/{STREAM_ID}?{TOKEN}"
```

Replace `{STREAM_ID}` and `{TOKEN}` with the values from the **URLs for encoder** section of the live stream settings. The example uses synthetic video and audio sources for testing.

## Pushing via SRT

The SRT example keeps the same H.264/AAC encoding settings, then packages the output as MPEG-TS and sends it through `srtsink`:

```sh theme={null}
gst-launch-1.0 -v \
    videotestsrc is-live=true pattern=smpte ! \
        video/x-raw,format=I420,width=1920,height=1080,framerate=30/1 ! \
        x264enc tune=zerolatency bitrate=3000 speed-preset=veryfast key-int-max=60 bframes=0 ! \
        h264parse config-interval=1 ! queue ! mux. \
    audiotestsrc is-live=true wave=sine ! \
        audio/x-raw,channels=2,rate=48000 ! \
        avenc_aac bitrate=128000 ! queue ! mux. \
    mpegtsmux name=mux ! \
    srtsink uri="srt://vp-push-ed2-srt.gvideo.co:5001" \
            mode=caller latency=1500 \
            streamid="{STREAM_ID}#{TOKEN}"
```

Pass the value after `?streamid=` as the separate `streamid` parameter. This avoids URI parsing issues caused by the `#` separator between the stream ID and token.

Replace `{STREAM_ID}` and `{TOKEN}` with the values from the portal SRT URL.

## Pipeline notes

* `videotestsrc pattern=smpte` and `audiotestsrc wave=sine` are synthetic sources that produce color bar video and a sine tone. Use them to verify the pipeline without a physical camera. Replace them with the appropriate GStreamer source elements when streaming from a real device or file.
* `x264enc tune=zerolatency` combined with `key-int-max=60` and `bframes=0` produces a keyframe every 2 seconds at 30 fps and avoids B-frames, keeping latency low for live ingest.
* For this RTMP pipeline, `flvmux streamable=true` produces a live FLV stream suitable for RTMP ingest — it enables output of the FLV header before all streams are configured.
* `mpegtsmux` multiplexes H.264 and AAC into MPEG-TS, the container used by Gcore SRT ingest. This is why RTMP uses `flvmux` and SRT uses `mpegtsmux`.
