diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-01-09 21:46:30 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-01-09 21:46:30 +0100 |
commit | 57177258d2878c4bded414944d2f5354c4d744b6 (patch) | |
tree | 9610dfebff63726babc1eaa1bd985f919d35b604 /src/tools | |
parent | 4ed29d46d45a751071d89be37c87de71204efda4 (diff) | |
download | notes-57177258d2878c4bded414944d2f5354c4d744b6.tar.gz notes-57177258d2878c4bded414944d2f5354c4d744b6.zip |
ffmpeg: record x11 window
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/README.md | 1 | ||||
-rw-r--r-- | src/tools/ffmpeg.md | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/README.md b/src/tools/README.md index d6b0a21..fd8ee7e 100644 --- a/src/tools/README.md +++ b/src/tools/README.md @@ -14,3 +14,4 @@ - [qemu](./qemu.md) - [pacman](./pacman.md) - [dot](./dot.md) +- [ffmpeg](./ffmpeg.md) diff --git a/src/tools/ffmpeg.md b/src/tools/ffmpeg.md new file mode 100644 index 0000000..9f0c56b --- /dev/null +++ b/src/tools/ffmpeg.md @@ -0,0 +1,26 @@ +# ffmpeg (1) + +## screen capture specific window (x11) + +Following snippet allows to select a window which is then captured. +```bash +#!/bin/bash + +echo "Click on window to record .." +# Extract window size and x,y offset. +video_args=$(xwininfo \ + | awk '/Absolute upper-left X:/ { xoff = $4 } + /Absolute upper-left Y:/ { yoff=$4 } + /Width:/ { if ($2 % 2 == 1) { width=$2-1; } else { width=$2; } } + /Height:/ { if ($2 % 2 == 1) { height=$2-1; } else { height=$2; } } + END { printf "-video_size %dx%d -i :0.0+%d,%d", width, height, xoff, yoff }') + +ffmpeg -framerate 25 -f x11grab $video_args -pix_fmt yuv420p $@ output.mp4 +``` +> Use `yuv420p` pixel format if video is played on the web +> ([ref](https://stackoverflow.com/questions/32829514/which-pixel-format-for-web-mp4-video)) + +The input `-i 0,0+xoff,yoff` means to capture `$DISPLAY=0.0` starting at the +coordinate `(xoff, yoff)`, which is the left-upper corner, and the size of the +capture is defined by the `-video_size` argument. + |