Last active
November 25, 2015 22:48
-
-
Save rkmax/bcc3dd33f1e3241787e6 to your computer and use it in GitHub Desktop.
Screen cast using ffmpeg and libnotify
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 | |
# SCREENCAST | |
# USER SETTINGS | |
OUTPUT="$(xdg-user-dir VIDEOS)/Screencast" | |
WAITSEC=3 | |
# VARIABLES | |
SIZE="1366x768" | |
RATE="23" | |
VCODEC="libx264" | |
PIXELS="yuv420p" | |
PRESET="medium" | |
if [[ ! -d "$OUTPUT" ]]; then | |
mkdir -p $OUTPUT | |
fi | |
if [[ $(ps cax | grep -q ffmpeg) ]]; then | |
killall -INT -w ffmpeg | |
fi | |
# notification - starting | |
notify-send -t $(($WAITSEC -2)) "Screencast will begin in $WAITSEC seconds" | |
# pause! | |
sleep $WAITSEC | |
SCREENCAST_NAME="$OUTPUT/$(date "+%F.%H-%M-%S")" | |
# start screencasting losslessly without audio | |
ffmpeg \ | |
-f x11grab \ | |
-s $SIZE -r $RATE -i :0.0 \ | |
-c:v $VCODEC -tune stillimage \ | |
-crf 18 -pix_fmt $PIXELS -preset $PRESET \ | |
-threads 4 -qp 0 \ | |
-y ${SCREENCAST_NAME}.mp4 | |
# notification - completion | |
MSG="Screen case ${SCREENCAST_NAME} finished :-)" | |
echo ${MSG} | |
notify-send -t 3000 ${MSG} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment