I was able to convert MP4 to GIF with ffmpeg with the following commands on Ubuntu 22.04:
ffmpeg \
-i iphone884.mp4 \
-r 15 \
-vf "scale=512:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
-ss 00:00:03 -to 00:00:06 \
iphone884.gif
ffmpeg \
-i iphone884.mp4 \
-r 15 \
-vf "scale=300:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
iphone884.gif
How to create an animated GIF from MP4 video via command line?
https://askubuntu.com/questions/648603/how-to-create-an-animated-gif-from-mp4-video-via-command-line