Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save denji/52273d2a50e33278550487dc3a9e598f to your computer and use it in GitHub Desktop.
Save denji/52273d2a50e33278550487dc3a9e598f to your computer and use it in GitHub Desktop.
[Video Screen Capture with GStreamer] Capture a Linux desktop window video with gsteramer. #tags: gstreamer, linux, xwindows, video

Capture a video of a given X Window with gstreamer.

X Window ID

Get the target window ID with the following:

xwininfo

The window ID will look something like:

xwininfo: Window id: 0x60000f "xterm"

GStreamer screen capture video to file

From the gstreamer ximagesrc documentation (update the window ID as necessary):

gst-launch-1.0 ximagesrc xid=0x60000f ! video/x-raw,framerate=5/1 ! videoconvert ! theoraenc ! oggmux ! filesink location=desktop.ogg

Capture to x264 MP4

gst-launch-1.0 ximagesrc xid=0x60000f ! video/x-raw,framerate=5/1 ! videoconvert ! queue ! x264enc pass=5 quantizer=26 speed-preset=6 ! mp4mux fragment-duration=500 ! filesink location="capture.mp4"

To Do

Convert this to a bash script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment