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 | |
parent | 4ed29d46d45a751071d89be37c87de71204efda4 (diff) | |
download | notes-57177258d2878c4bded414944d2f5354c4d744b6.tar.gz notes-57177258d2878c4bded414944d2f5354c4d744b6.zip |
ffmpeg: record x11 window
Diffstat (limited to 'src')
-rw-r--r-- | src/SUMMARY.md | 1 | ||||
-rw-r--r-- | src/tools/README.md | 1 | ||||
-rw-r--r-- | src/tools/ffmpeg.md | 26 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 79af5fc..e77c09e 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -17,6 +17,7 @@ - [qemu](./tools/qemu.md) - [pacman](./tools/pacman.md) - [dot](./tools/dot.md) + - [ffmpeg](./tools/ffmpeg.md) - [Resource analysis & monitor](./monitor/README.md) - [lsof](./monitor/lsof.md) 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. + |