Gstreamer pipeline

From damionrashford/media-os · View interactive version

Gstreamer pipeline is an AI agent skill from the GitHub repository damionrashford/media-os. Build and run GStreamer pipelines with gst-launch-1.0, introspect elements with gst-inspect-1.0, discover media with gst-discoverer-1.0, enumerate devices with gst-device-monitor-1.0, play files with gst-play-1.0, detect type with gst-typefind-1.0. Pipeline syntax (element ! element, named elements,

How to use this skill

Skill file

GStreamer Pipeline

Context: $ARGUMENTS

Quick start

When to use

For documentation lookup (which properties does hlssink2 expose? what does webrtcbin support?), use the gstreamer-docs skill first.


Step 1 — Check GStreamer is installed

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py inspect --element filesrc --dry-run

If this errors with "gst-inspect-1.0 not found", install:

Verify plugin sets are present; many elements (e.g. webrtcbin, hlssink2, srtsink, x264enc) ship in -bad or -ugly or Rust plugins (gst-plugins-rs).


Step 2 — Introspect an element before using it

Never hand-assemble an element's properties from memory. Use:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py inspect --element webrtcbin
uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py inspect --element hlssink2
uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py inspect --element x264enc

List every factory:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py list-elements
uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py list-elements --plugin coreelements

Find which elements handle a URI scheme (e.g. rtsp://):

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py inspect --uri-handlers

Filter by factory type:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py inspect --types "Codec/Encoder/Video"

Pair with the gstreamer-docs skill for the canonical URL and full property table if the CLI output is terse.


Step 3 — Probe devices and media

Discover streams, caps, duration, tags of a file or URL:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py discover --uri file:///path/to/file.mp4
uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py discover --uri rtsp://camera.local/stream -v -t 10

List capture + output devices:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py devices
uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py devices --classes "Video/Source" "Audio/Source"
uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py devices --follow   # watch add/remove events

Typefind (MIME / caps) on a blob:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py typefind /tmp/unknown.bin

Step 4 — Run a pipeline with `launch`

Use -- to separate pipeline tokens from gst.py flags, then write the pipeline in GStreamer shell syntax:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py launch -- \
  videotestsrc num-buffers=300 \
  ! video/x-raw,width=1280,height=720,framerate=30/1 \
  ! timeoverlay \
  ! autovideosink

Enable verbose caps negotiation:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py launch -v -- videotestsrc ! fakesink

Set GST_DEBUG without manual env export:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py launch \
  --debug-level "3,webrtcbin:6" \
  --debug-file /tmp/gst.log \
  --verbose-tool -e -- \
  videotestsrc ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5000

Add --eos-on-shutdown when writing to a muxer so Ctrl-C finalises the file cleanly (otherwise matroskamux / mp4mux leave a truncated output).

Dry-run echoes the exact gst-launch-1.0 invocation and exits:

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py launch --dry-run -- filesrc location=in.mp4 ! decodebin ! autovideosink

Step 5 — Quick playback with `play`

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py play video.mp4
uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py play rtsp://cam/stream --audio-only
uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py play video.mp4 --no-interactive

--no-interactive disables keyboard controls — use this in any non-interactive agent run.


Step 6 — Grab a recipe

CODE0 has 15+ production-ready pipelines:

Read references/pipelines.md when the user needs a starting pipeline for any of the above.


Gotchas


Examples

Example 1: "Play an MP4 with verbose caps"

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py launch -v -- \
  filesrc location=in.mp4 ! decodebin3 ! videoconvert ! autovideosink

Example 2: "Record my webcam + mic to MP4 for 30 seconds (macOS)"

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py launch -e -- \
  avfvideosrc device-index=0 ! video/x-raw,width=1280,height=720 \
  ! videoconvert ! x264enc tune=zerolatency bitrate=3000 ! h264parse \
  ! qtmux name=mux ! filesink location=out.mp4 \
  avfaudiosrc ! audioconvert ! audioresample ! avenc_aac bitrate=128000 \
  ! mux. \
  --eos-on-shutdown

(Kill with Ctrl-C after 30s; -e ensures qtmux finalises.)

Example 3: "Probe an RTSP camera for its streams"

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py discover \
  --uri rtsp://admin:pw@10.0.0.42/stream -v -t 10

Example 4: "What video inputs can I record from?"

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py devices --classes "Video/Source"

Example 5: "Dump the full property list for webrtcbin"

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py inspect --element webrtcbin

Example 6: "Publish a test pattern to MediaMTX via WHIP"

uv run ${CLAUDE_SKILL_DIR}/scripts/gst.py launch -v -e -- \
  videotestsrc is-live=true \
  ! video/x-raw,width=1280,height=720,framerate=30/1 \
  ! videoconvert \
  ! 'whipclientsink name=ws signaller::whip-endpoint=http://127.0.0.1:8889/live/whip'

(Requires gst-plugins-rs; fall back to a webrtcsink + signaller setup if absent.)


Troubleshooting

`WARNING: erroneous pipeline: no element "webrtcbin"`

Cause: Plugin not installed.

Solution: webrtcbin lives in gst-plugins-bad. Install it: macOS brew install gst-plugins-bad; Debian/Ubuntu apt install gstreamer1.0-plugins-bad libnice-dev. Verify with gst-inspect-1.0 webrtcbin.

`could not link filesrc0 to decodebin0`

Cause: filesrc produces ANY caps, but some decoders want a typefind step.

Solution: Insert decodebin3 which handles typefind internally: filesrc location=in.mp4 ! decodebin3 ! .... Or use uridecodebin3 uri=file:///....

`gst-launch-1.0: command not found`

Cause: Tools not on PATH, or only gst-launch installed without the -1.0 suffix (very old GStreamer).

Solution: Reinstall GStreamer 1.x. On macOS homebrew: brew install gstreamer.

Output MP4 from the recording pipeline is 0 bytes or unplayable

Cause: Process killed without EOS -> qtmux / mp4mux never wrote the moov atom.

Solution: Re-run with -e / --eos-on-shutdown, use Ctrl-C only once, then wait 1-2s for finalisation.

`avfvideosrc` opens but produces no frames on macOS

Cause: Privacy permission not granted to the terminal / IDE running gst-launch.

Solution: macOS System Settings -> Privacy & Security -> Camera -> add your terminal. Restart the terminal after granting.

Pipeline runs but no audio in output

Cause: Missing queue on the audio branch of a muxer fan-in, or wrong sample rate.

Solution: Insert queue ! audioconvert ! audioresample before the muxer pad. Ensure mux. syntax attaches to the named mux element.

"Delayed linking failed for: webrtcbin.sink"

Cause: webrtcbin refuses RTP caps that don't specify payload-type / encoding-name.

Solution: Add a capsfilter: rtph264pay config-interval=-1 pt=96 ! application/x-rtp,media=video,encoding-name=H264,payload=96 ! webrtcbin.


Reference docs

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.