Skip to content

Instantly share code, notes, and snippets.

@y1zhou
Created February 2, 2023 08:50
Show Gist options
  • Save y1zhou/0c787d0f3226c18a3161f58d16d88175 to your computer and use it in GitHub Desktop.
Save y1zhou/0c787d0f3226c18a3161f58d16d88175 to your computer and use it in GitHub Desktop.
Generate an mp4 slideshow from png images
ffmpeg \
-framerate 1 \
-pattern_type glob \
-i '*.png' \
-c:v libx264 \
-vf 'pad=ceil(iw/2)*2:ceil(ih/2)*2' \
-pix_fmt yuv420p \
slideshow.mp4
@y1zhou
Copy link
Author

y1zhou commented Feb 17, 2023

If the list of images is numerically-ordered, try this instead:

cat $(find . -type f -iname '*.png' -exec basename {} \; | sort -gs) | ffmpeg \
  -f image2pipe \
  -r 2 -i - -r 2 \
  -c:v libx264 \
  -vf 'pad=ceil(iw/2)*2:ceil(ih/2)*2' \
  -pix_fmt yuv420p \
  slideshow.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment