TIL: FFmpeg is Pretty Neat
So I recently needed to make a GIF on my linux desktop (PopOS) but had no idea how to approach it. Some searching around told me I'd need to take a screen capture so I defaulted to the GNOME screenshot tool.
Ctrl-Shift-Alt-R opens the option to take a screencapture instead of just a screenshot. However I soon ran into issues where the video output was freezing after the first few seconds. Not wanting to get sidetracked running down why that wasn't working (this turned out to be an issue in gstreamer/pipewire).
I started looking for other tools which lead me to ffmpeg. I was vaguely aware that ffmpeg was the go-to tool for video manipulation, but hadn't needed it before.
Turns out FFMPEG is pretty neat! You can get the simple 'grab-box' style UI using the -select_region flag. No need for specific cordinates or monitor ids.
ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -select_region 1 -i :1.0 i.mp4
Trimming the recording was also pretty easy. The flag -ss 5 seeks 5 seconds into the video and -t 40 to stop writing after 40 seconds of video output.
ffmpeg -i i.mp4 -ss 5 -t 40 output.mp4
Then I could chunk the video into frames with:
ffmpeg -i output.mp4 -r 5 frames/frame%3d.png
The last bit was to open all these frames as layers if GIMP and (after some cleanup / optimization) export it as an animated GIF!