screen capture script

I’m trying to conceptualize how big of an area to capture without actually drawing a picture and doing math on paper. Why is this harder?

I want to capture the center of the screen, a window of arbitrary size.

RESOLUTION=$(xrandr --current | grep '\*' | awk '{print $1}')
[[ "${RESOLUTION}" =~ ([0-9]+)x([0-9]+) ]] || exit 1
RES_X=${BASH_REMATCH[1]}
RES_Y=${BASH_REMATCH[2]}
D_W=$((RES_X/4))
D_H=$((RES_Y/4))

OFF_X=$((RES_X/2 - D_W/2))
OFF_Y=$((RES_Y/2 - D_H/2))

ffmpeg -video_size "${D_W}x$(D_H}" -framerate 25 -f x11grab -i :0.0+${OFF_X},${OFF_X} output.mp4

Tags

#cli

Navigation

index

tags

updated: 2023-02-17 06:34:31

generated: 2024-03-07