Skip to content

Instantly share code, notes, and snippets.

@stephanbogner
Last active July 28, 2021 11:51
Show Gist options
  • Select an option

  • Save stephanbogner/65617c93edb98e91d75822279b443e17 to your computer and use it in GitHub Desktop.

Select an option

Save stephanbogner/65617c93edb98e91d75822279b443e17 to your computer and use it in GitHub Desktop.
Convert series of images to .webm video file with transparent background using ffmpeg
// Convert all images in directory
ffmpeg -framerate 30 -pattern_type glob -i '*.png' -pix_fmt yuva420p _export.webm
// For image names frame-1.png, frame-2.png, frame-3.png, etc.
ffmpeg -framerate 30 -i frame-%d.png -pix_fmt yuva420p _export.webm
// For image names frame-00001.png, frame-00002.png, frame-00003.png, etc. (5 apparently stand for the length of the number)
ffmpeg -framerate 30 -i frame-%05d.png -pix_fmt yuva420p _export.webm
#!/bin/bash
# Note: I did not figure out why executing the commands did not work. But it logs to the terminal, so you can copy and paste it and it works
#echo $PWD/*
for dir in $PWD/*
do
if [[ -d $dir ]]; then
#echo $dir
for subdir in $dir/*
do
if [[ -d $dir ]]; then
#echo $subdir
filename="$(basename $subdir)"
cmd="ffmpeg -framerate 30 -pattern_type glob -i '${subdir}/*.png' -pix_fmt yuva420p $PWD/${filename}.webm"
echo $cmd";"
#$cmd
fi
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment