Created
February 19, 2020 20:27
-
-
Save szkrd/6694b1b070ca0010b4397982bc95f433 to your computer and use it in GitHub Desktop.
record window on x11 using ffmpeg
This file contains 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 | |
NOCOLOR='\e[0m' | |
RED='\e[0;31m' | |
GREEN='\e[0;32m' | |
YELLOW='\e[1;33m' | |
CYAN='\e[0;36m' | |
command -v ffmpeg >/dev/null 2>&1 || { echo >&2 "${RED}ffmpeg not installed!${NOCOLOR}"; exit 1; } | |
echo -e "You can select a window for ${CYAN}fixed coordinates${NOCOLOR} in 3 seconds." | |
sleep 3 | |
echo "Select window!" | |
XW="$(xwininfo)" | |
W=$(echo "${XW}" | grep 'Width:' | sed 's/[^0-9]//g') | |
H=$(echo "${XW}" | grep 'Height:' | sed 's/[^0-9]//g') | |
X=$(echo "${XW}" | grep 'Absolute upper-left X:' | sed 's/[^0-9]//g') | |
Y=$(echo "${XW}" | grep 'Absolute upper-left Y:' | sed 's/[^0-9]//g') | |
FN=~/Videos/$(date +'%Y%m%d_%H%M%S').mp4 | |
echo -e "${CYAN}Size:${NOCOLOR} ${W}x${H}" | |
echo -e "${CYAN}Coord:${NOCOLOR} X=${X} Y=${Y}" | |
echo -e "${CYAN}Output:${NOCOLOR} ${FN}" | |
echo -e "Starting in ${GREEN}3${NOCOLOR}" && sleep 1 | |
echo -e "Starting in ${YELLOW}2${NOCOLOR}" && sleep 1 | |
echo -e "Starting in ${RED}1${NOCOLOR}" && sleep 1 | |
echo -e "${RED}=============================================${NOCOLOR}" | |
ffmpeg -f x11grab -s ${W}x${H} -i :0.0+${X},${Y} -r 25 -vcodec libx264 ${FN} | |
if [ -f "${FN}" ]; then | |
echo -e "${GREEN}File saved:${NOCOLOR} $(ls -sh ${FN})" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment