Created
April 15, 2018 18:30
-
-
Save ruzickap/90fdf1823c8c8ba5ccdaf8a15e87c749 to your computer and use it in GitHub Desktop.
Simple script to record desktop in the background using ffmpeg and ImageMagick
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
#!/bin/bash -eux | |
DESTINATION_VIDEO_FILE="$HOME/Videos/`date +%F_%T`.mkv" | |
DESTINATION_SCREENSHOT_DIRECTORY="$HOME/Pictures/" | |
MAX_RECORDING_TIME="18000" #seconds (5 hours) | |
echo "*** $DESTINATION_VIDEO_FILE" | |
ffmpeg -loglevel error -f x11grab -draw_mouse 1 -framerate 25 -video_size 1920x1080 -i :0+0,0 -pix_fmt yuv420p -c:v libx265 -x265-params crf=28 -preset veryfast -to ${MAX_RECORDING_TIME} $DESTINATION_VIDEO_FILE & | |
echo $! > /tmp/`basename $0`_video.pid | |
echo "*** $DESTINATION_SCREENSHOT_DIRECTORY" | |
COUNTER=0 | |
( | |
while [ $(( COUNTER * 10 )) -le $MAX_RECORDING_TIME ]; do | |
COUNTER=$((COUNTER+1)) | |
import -window root ${DESTINATION_SCREENSHOT_DIRECTORY}/`date +%F_%T`.png & | |
sleep 10 | |
done | |
) & | |
echo $! > /tmp/`basename $0`_pics.pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment