Skip to content

Instantly share code, notes, and snippets.

@benbjohnson
Created August 28, 2013 23:22
Show Gist options
  • Save benbjohnson/6372609 to your computer and use it in GitHub Desktop.
Save benbjohnson/6372609 to your computer and use it in GitHub Desktop.
Generate a video of frame numbers.
#!/bin/bash
# Generate the frames
for i in {0..1800}
do
echo "Generating frame $i"
convert -background black -fill white -size 480x320 -pointsize 48 -gravity center label:${i} frame${i}.png
done
# Combine frames into H.264 MP4 video. (29.97fps & 30fps)
ffmpeg -i frame%d.png -t 60.06 -codec:v libx264 -r 30000/1001 29_97fps.mp4
ffmpeg -i frame%d.png -t 60 -codec:v libx264 -r 30 30fps.mp4
# Clean up frames.
rm frame*.png
@jmodjeska
Copy link

Thank you for this.

Per this post, the default pixel format isn't compatible with QuickTime. Appending a pixel format worked for me:

ffmpeg -i frame%d.png -t 60 -codec:v libx264 -r 30 -pix_fmt yuv420p 30fps.mp4

@meisa233
Copy link

 ffmpeg -r 30 -i frame%d.png -c:v libx264 -pix_fmt yuv420p ~/720p_30fps.mp4

This works for me.

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