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 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 | |
# 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→ web.de>. | |
# Check <https://gist.github.com/4572552> for newer versions. | |
# Resources | |
# * http://www.itforeveryone.co.uk/image-to-video.html | |
# * http://spielwiese.la-evento.com/hokuspokus/index.html | |
# * http://ffmpeg.org/trac/ffmpeg/wiki/Create%20a%20video%20slideshow%20from%20images | |
# * http://wiki.ubuntuusers.de/FFmpeg | |
set -x | |
FRAMERATE=4 | |
RESOLUTION=1920x1080 | |
# Rename the images into a sequence | |
# http://www.ralree.com/2008/08/06/renaming-files-sequentially-with-bash/ | |
EII=1 | |
# 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` | |
done | |
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I couldn't play this converted mp4 file in any media player.Can you please give me the solution