Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert video to gif
[Desktop Entry]
Type=Action
TargetLocation=true
ToolbarLabel[en_US]=Convert to Animated GIF
ToolbarLabel[en]=Convert to Animated GIF
ToolbarLabel[C]=Convert to Animated GIF
Name[en_US]=Convert to Animated GIF
Name[en]=Convert to Animated GIF
Name[C]=Convert to Animated GIF
Profiles=profile-zero;
[X-Action-Profile profile-zero]
MimeTypes=video/mp4;
ExecutionMode=Terminal
Exec=~/bin/vid2gif.sh %F %d/%W.gif
Name[en_US]=Convert to Animated GIF
Name[en]=Convert to Animated GIF
Name[C]=Convert to Animated GIF
#!/bin/sh
ACTIONS_DIR=~/.local/share/file-manager/actions
sudo apt-get install nautilus-actions
mkdir -p $ACTIONS_DIR
mv ./Convert\ to\ Animated\ GIF $ACTIONS_DIR/Convert\ to\ Animated\ GIF
chmod +x ~/bin/vid2gif.sh
#!/bin/sh
# vid2gif
# converts videos to gifs
read -p 'Width (default 540): ' G_WIDTH
read -p 'FPS (default 10): ' G_FPS
G_WIDTH=${G_WIDTH:-540}
G_FPS=${G_FPS:-10}
PALETTE="/tmp/palette.png"
FILTERS="fps=$G_FPS,scale=$G_WIDTH:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$FILTERS,palettegen" -y $PALETTE
ffmpeg -v warning -i $1 -i $PALETTE -lavfi "$FILTERS [x]; [x][1:v] paletteuse" -y $2
# remove tmp/palette.png
rm -f $PALETTE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.