Creating Timelapses With FFMPEG

Introduction

Recently I needed to create a timelapse for a project that I was working on and ran into the issue of encoding video footage from individually captured pictures.  To prevent myself from running into this problem again I’m recording the solution to it here.  My requirements on the project were that I wanted to encode the video in a high quality intermediate codec in 4k quality to enable editing down the line.  I also wanted to do this using an open source solution if possible.

Relabeling

Fortunately, it turns out the open source multimedia program ffmpeg actually contains an open source Apple ProRes encoder.  Unfortunately, to input image files, the application requires that they are labeled with a running sequence of numbers in the file name.  IE “IMG_0001.jpg”, “IMG_002.jpg”…  While many cameras do number images like this, mine skipped a couple of numbers which caused problems during encoding.  I also had multiple shots in a single folder.

My first step was to separate out each of the shots into their own directories.  I marked down the range of files from each shot by opening them up in an image viewer and moved them to the directories.  Once that was done, I had to relabel all of the images with sequential numbers to enable ffmpeg to work its magic.  This was achieved simply on linux with the following BASH script:

a=1
for i in *.JPG; do
new=$(printf “%04d.jpg” “$a”) #04 pad to length of 4
mv -i — “$i” “$new”
let a=a+1
done

Encoding

The actual command to perform the encoding is rather simple:

ffmpeg -f image2 -r 24 -start_number 0001 -i %04d.jpg -s 3840×2160 -vcodec prores -profile:v 3 .output.mov

-f image2 specifies that the input file format is jpeg
-r 24 tells the program to encode at a frame rate of 24 FPS
-start_number 0001 sets the index of the first picture to use
%04d.jpg is the filename of the input pictures.  ffmpeg will replace %04d with a number padded with zeros to four characters (0001, 0002, 0003, …)
-s 3840×2160 is the resolution of the frame, 4k UHD in this case
-vcodec prores sets the codec to be Apple ProRes
-profile:v 3 is the profile used by the ProRes encoder:
From the ffmpeg manual there are the following options:
0 – “proxy”
1 – “lt”
2 – “standard”
3 – “hq”
output.mov, finally is the output filename

Executing this command in the folder containing my images from each shot generated video files encoded at about 1Gbit/S in Apple ProRes.

Centos Update Breaks ZFS Module

I decided to update my kernel on Centos 7 the other day on my NFS server.  When I rebooted and tried to access my ZFS media I discovered the error:

The ZFS modules are not loaded.

Trying to run modprobe just showed that the module were not installed in the system.  This was strange, as the ZFS package was still installed.  I turns out that there has long been an issue of kernel compatibility with the Centos ZFS package.  What follows are the steps I used to fix the issue since it isn’t well documented elsewhere.

Step 1: Remove ZFS

The first issue is that the ZFS package will simply update itself and thus the kernel module to reflect changes to the running linux kernel.  For whatever reason, the package maintainers recommend fully removing the package when issues with compatibility arise.  This may be done by the command

yum remove zfs zfs-kmod spl spl-kmod libzfs2 libnvpair1 libuutil1 libzpool2 zfs-release

It may take a little while to run.

Step 2: Reinstall the ZFS RPM

Run the command

yum install http://download.zfsonlinux.org/epel/zfs-release.el7_4.noarch.rpm

to reinstall the RPM and optionally run the command

yum autoremove

to remove any orphaned packages in the tree.  At this point, I intended to install the kmod version of the ZFS package instead of the DKMS package that will be installed by default.  I found that the DKMS version caused problems when I installed it the first time around.

The change may be made by modifying /etc/yum.repos.d/zfs.repo  and disabling the zfs package and enabling the zfs-kmod package.  Detailed instructions can be found here.

Step 3: (Re)install ZFS

Run the command

yum install zfs

to reinstall the zfs package.  After this finishes, you should be able to run

modprobe zfs

and  use the ZFS package as normal.  If this still does not work, I would recommend checking to see if your kernel, kernel-devel, and kernel-headers packages all have the same version as they may not correctly synchronize during a full system upgrade.

Scroll to top