Making time-lapse video using ffmpeg

# create-mp4 

if [ $# -ne 2 ]
    echo "Usage: `basename $0` fps outfile.mp4"
    echo "fps format is 1/seconds, i.e. 1/0.05"
    exit 1

# 1/0.05 is 20fps
# "scale=1280:720" will produce 1280x720 resolution
cat *.jpg | ffmpeg -f image2pipe -r $fps -vcodec mjpeg -i - -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -vcodec libx264 $ofile

Previous ffmpeg options can’t handle odd size of width or height of JPEG image files such as 1073×720. FFMPEG (libx264) “height not divisible by 2”

cat *.jpg | ffmpeg -f image2pipe -s 1280x720 -r $fps -vcodec mjpeg -i - -vcodec libx264 $ofile

Understanding FFmpeg – Part II: Scaling video

About janpenguin

Email: k2.mountain [at] gmail [dot] com Every content on the blog is made by Free and Open Source Software in GNU/Linux.
This entry was posted in GNU/Linux and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s