Last active
July 19, 2021 15:30
-
-
Save Tobiaqs/b566bcc4a6e7c905c013b06742b02664 to your computer and use it in GitHub Desktop.
Script for creating GIFs from files created by Pop_OS!'s screen recording functionality
This file contains hidden or 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 | |
# Requirements: | |
# - ffmpeg | |
# - xdotool | |
MAX_W=720 | |
read -p "Press a key to select top left corner of region" | |
topleft_x=$(xdotool getmouselocation | awk '{print $1}' | cut -d':' -f 2) | |
topleft_y=$(xdotool getmouselocation | awk '{print $2}' | cut -d':' -f 2) | |
read -p "Press a key to select bottom right corner of region" | |
bottomright_x=$(xdotool getmouselocation | awk '{print $1}' | cut -d':' -f 2) | |
bottomright_y=$(xdotool getmouselocation | awk '{print $2}' | cut -d':' -f 2) | |
w=`expr $bottomright_x - $topleft_x` | |
h=`expr $bottomright_y - $topleft_y` | |
file=$(ls --sort=time $HOME/Videos | grep Screencast | head -n1) | |
scale=$w | |
if [[ $w -gt $MAX_W ]]; then | |
scale=$MAX_W | |
fi | |
ffmpeg -i "$HOME/Videos/$file" -filter:v "crop=$w:$h:$topleft_x:$topleft_y,fps=10,scale=$scale:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" "$HOME/Videos/$file.gif" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment