Skip to content

Instantly share code, notes, and snippets.

Last active December 23, 2019 09:51
What would you like to do?
A Bash script to create a video from series of JPEG images. Ideal to create videos from timed sequences shot with a tripod. It uses mogrify (from imagemagick) to resize the images to FullHD and it then uses ffmpeg to create a video from the sequence of images.
# This is a script to create a video from series of JPEG images
# Call it in a folder full of JPEGs that you want to turn into a video.
# Written on 2013-01-08 by Philipp Klaus <philipp.l.klaus →AT→>.
# Check <> for newer versions.
# Resources
# *
# *
# *
# *
set -x
# Rename the images into a sequence
# If sorting according to the file date, copy them using cp -a ../*.JPG ./
for i in $(ls -tr *.JPG); do
ls $i
NEWNAME=IMG_`printf "%05d" $EII`.JPG
#echo Renaming $i to $NEWNAME
mv $i $NEWNAME
EII=`expr $EII + 1`
# Resize the images (replaces the files)
mogrify -resize $RESOLUTION *.JPG
# Now create the video using ffmpeg
cat *.JPG | ffmpeg -f image2pipe -r $FRAMERATE -vcodec mjpeg -i - -vcodec libx264 out_$FRAMERATE.mp4
#ffmpeg -f image2 -r $RATE -i IMG_%05d.JPG movie_$RATE.mp4
Copy link

I couldn't play this converted mp4 file in any media player.Can you please give me the solution

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