Skip to content

Instantly share code, notes, and snippets.

@M3nti0nL3Ss
Last active December 26, 2020 23:48
Show Gist options
  • Save M3nti0nL3Ss/edc91213a30d89d0d63a21f09dbdcdff to your computer and use it in GitHub Desktop.
Save M3nti0nL3Ss/edc91213a30d89d0d63a21f09dbdcdff to your computer and use it in GitHub Desktop.
Auto shell screen recorder for lazy students
#!/bin/bash
# M3nti0nl3ss Copyright (c) 2020
# ./record.sh [time in seconds]
# To record until manual interruption just run ./record.sh
A="$(pacmd list-sources | grep -PB 1 "analog.*monitor>" | head -n 1 | perl -pe 's/.* //g')"
F="$(date --iso-8601=minutes | perl -pe 's/[^0-9]+//g').mkv"
V="$(xprop -root | grep '_NET_DESKTOP_GEOMETRY' | head -n 1 | tail -c 10 | sed -r 's/[,]+/x/g' | sed -r 's/[ ]+//g')"
if [ $# -eq 1 ]; then
ffmpeg -loglevel error -video_size "$V" -f x11grab -i :0.0 -f pulse -i "$A" -f pulse -i default -filter_complex amerge -ac 2 -preset veryfast "$F" &
sleep $1
kill -9 $(pidof ffmpeg)
else
ffmpeg -loglevel error -video_size "$V" -f x11grab -i :0.0 -f pulse -i "$A" -f pulse -i default -filter_complex amerge -ac 2 -preset veryfast "$F"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment