-
-
Save hn-88/95dbd59767dcdff23eab2f2be5880c2f to your computer and use it in GitHub Desktop.
Generate a video of frame numbers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 -r 30 -i frame%d.png -t 60 -codec:v libx264 -r 30 30fps.mp4 | |
# Clean up frames. | |
rm frame*.png |
Found some frames are being duplicated. Investigating. Something related to
https://superuser.com/questions/1255380/ffmpeg-duplicating-frames
?
ffmpeg says
encoded 433 frames in 4.02s (107.71 fps), 70.96 kb/s, Avg QP:35.13
for command
ffmpeg -i frame%d.png -codec:v libx265 -r 30 30fps.mp4
even tho there are only 360 frames in the input.
Every 5 frames, it's adding a duplicate frame.
Just giving ffmpeg -i frame%d.png default.mp4
results in a 25fps mp4.
For getting the desired result, we have to put the -r before the -i, like
ffmpeg -r 30 -i frame%d.png thisis30fps.mp4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On windows, we have to use the command "magick" instead of "convert" according to
https://stackoverflow.com/questions/4481573/how-to-override-windows-convert-command-by-imagemagicks-one