Created
September 25, 2024 07:21
-
-
Save Loupax/921f6ef9a4a928bb8f3cd3c969d1653e to your computer and use it in GitHub Desktop.
Script that records the area of a window clicked by the user. Requires ffmpeg with Xcb enabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
window_info=$(xwininfo) | |
x=$(echo "$window_info" | grep "Absolute upper-left X" | awk '{print $4}') | |
y=$(echo "$window_info" | grep "Absolute upper-left Y" | awk '{print $4}') | |
width=$(echo "$window_info" | grep "Width" | awk '{print $2}') | |
height=$(echo "$window_info" | grep "Height" | awk '{print $2}') | |
if [ -z "$x" ] || [ -z "$y" ] || [ -z "$width" ] || [ -z "$height" ]; then | |
echo "Failed to get window geometry." | |
exit 1 | |
fi | |
timestamp=$(date +"%Y-%m-%d %H:%M:%S") | |
output_file="$HOME/Videos/${timestamp}.mp4" | |
# Run ffmpeg to record the selected window | |
ffmpeg -video_size "${width}x${height}" -framerate 25 -f x11grab -i ":0.0+${x},${y}" "$output_file" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment