Skip to content

Instantly share code, notes, and snippets.

@nuclearghost
Created September 15, 2015 19:48
Show Gist options
  • Save nuclearghost/95dce613b8e24454ed6c to your computer and use it in GitHub Desktop.
Save nuclearghost/95dce613b8e24454ed6c to your computer and use it in GitHub Desktop.
Create a gif from a mp4 using ffmpeg
#!/bin/bash
input_video=$1
starting_second=$2
lenght_in_seconds=$3
output_file=$4
palette="/tmp/palette.png"
filters="fps=15,scale=320:-1:flags=lanczos"
ffmpeg -ss $starting_second -t $lenght_in_seconds -i $input_video -vf "$filters,palettegen" -y $palette
ffmpeg -ss $starting_second -t $lenght_in_seconds -i $input_video -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $output_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment