Skip to content

Instantly share code, notes, and snippets.

@nin-jat
Created July 12, 2023 05:56
Show Gist options
  • Save nin-jat/d4221f8e54d2eb10ac65f93ebe4a5ea1 to your computer and use it in GitHub Desktop.
Save nin-jat/d4221f8e54d2eb10ac65f93ebe4a5ea1 to your computer and use it in GitHub Desktop.
Some scripts to record your screen as a timelapse. Worked on an old version of pop_os It's a great base to work from to make your own utilities. Requires FFMPEG and something called slop for grabbing the window rect.
#!/bin/bash
# The size of your displays
DISPLAY_SIZE=2560,1440
# The offset, zero is left.
DISPLAY_OFFSET=2560
# The speed to watch the timelapse back at (fps).
FRAMERATE=30
#FRAMERATE=60
# The speed to record the timelapse at (fps)
RECORD_RATE=1
# Reccord no sound
ffmpeg -s ${DISPLAY_SIZE} -framerate ${RECORD_RATE} -f x11grab -i :1.0+${DISPLAY_OFFSET} -vf settb=\(1/${FRAMERATE}\),setpts=N/TB/${FRAMERATE} -r ${FRAMERATE} output.mkv
#!/bin/bash
# Settings
#===============
#framerate=15
#framerate=30
framerate=60
#framerate=165
# Lower is better
quality=18
#===============
# Get the region to record in.
read -r X Y W H < <(slop --color=1,0,0,0.1 --bordersize=5 --highlight --format="%x %y %w %h")
echo $DISPLAY+$X,$Y
ffmpeg_defaults="-threads 4 -hide_banner -probesize 10M -framerate ${framerate} -vsync 1"
slop_x11_input="-thread_queue_size 128 -f x11grab -s ${W}x${H} -i $DISPLAY.0+$X,$Y"
#audio_input="-thread_queue_size 128 -f pulse -ac 2 -i default"
audio_input="-thread_queue_size 128 -f pulse -ac 2 -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor"
encoding="-c:v h264_nvenc -qp $quality";
output="/home/tom/Videos/screencaps/$(date +%F_%T).mp4"
# Record x11 with slop and audio.
#ffmpeg $ffmpeg_defaults $slop_x11_input $audio_input $output
# Reccord x11 with slop and audio using nvenc.
#ffmpeg $ffmpeg_defaults $slop_x11_input $audio_input -c:v h264_nvenc $output
# Reccord x11 with slop using nvenc.
ffmpeg $ffmpeg_defaults $slop_x11_input -c:v h264_nvenc $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment