From accd7763c5b8da55c6020bab4f7446033c8239f4 Mon Sep 17 00:00:00 2001 From: David Todd Date: Wed, 11 Sep 2019 15:39:52 -0500 Subject: [PATCH] Allow recording to gif screencast2gif will record a standard `ffcast` (just like pressing PrtSc) and then ffmpeg will convert it to gif format a short while later --- i3/config | 1 + i3/screencast2gif.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100755 i3/screencast2gif.sh diff --git a/i3/config b/i3/config index b494a12..a289310 100644 --- a/i3/config +++ b/i3/config @@ -75,6 +75,7 @@ bindsym $mod+Shift+Insert --release exec --no-startup-id maim ~/Pictures/$(date bindsym $mod+Ctrl+Insert exec --no-startup-id maim -s ~/Pictures/$(date +%Y-%m-%d).png&& pinta ~/Pictures/$(date +%Y-%m-%d-%s).png # screenshot and edit # Screen recording +bindsym Shift+Print exec --no-startup-id ~/.i3/screencast2gif.sh bindsym Print exec --no-startup-id "ffcast -q $(while slop -q -n -f '-g %g ';do :;done) rec ~/Videos/rec-%si-$(date +%Y-%m-%d-%s).mp4" bindsym $mod+Print exec --no-startup-id pkill -fxn '(/\S+)*ffmpeg\s.*\sx11grab\s.*' diff --git a/i3/screencast2gif.sh b/i3/screencast2gif.sh new file mode 100755 index 0000000..ac438f1 --- /dev/null +++ b/i3/screencast2gif.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +date=$(date +%Y-%m-%d-%s) + +ffmpeg() { + command ffmpeg -hide_banner -loglevel error -nostdin "$@" +} + +ffcast -q $(while slop -q -n -f '-g %g ';do :;done) rec ~/Videos/screencast-${date}.mp4 + +ffmpeg -i ~/Videos/screencast-${date}.mp4 -vf palettegen -f image2 -c:v png - | + ffmpeg -i ~/Videos/screencast-${date}.mp4 -i - -filter_complex paletteuse ~/Pictures/screencast-${date}.gif && notify-send "Gif recorded to ~/Pictures/screencast-${date}"