Skip to content

Instantly share code, notes, and snippets.

@cskonopka
Created August 3, 2019 03:05
Show Gist options
  • Save cskonopka/1e683cef107bca248473e651f9d26b2b to your computer and use it in GitHub Desktop.
Save cskonopka/1e683cef107bca248473e651f9d26b2b to your computer and use it in GitHub Desktop.
Search a directory for .mp4 files, create a .png using the "palettegen" filter and then generate a new gif using the .png and source .mp4
#!/bin/bash
echo "Provide a directory please :"
read dir
for f in $dir/*.mp4
do
echo "Processing $f"
echo "${f%.*}.png"
ffmpeg -y -ss 0 -t 11 -i $f -filter_complex "[0:v] palettegen" "${f%.*}.png"
ffmpeg -ss 0 -t 11 -i $f -filter_complex "[0:v] fps=24,scale=w=480:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" "${f%.*}.gif"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment