Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple script to record desktop in the background using ffmpeg and ImageMagick
#!/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
You can’t perform that action at this time.