Making time-lapse video using ffmpeg

#!/bin/bash
# create-mp4 

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

# 1/0.05 is 20fps
fps=$1
ofile=$2
# "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: janpenguin [at] riseup [dot] net 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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s