In this article I am going to show you how to convert a sequence of images (PNGs in this case) into a clip that can be uploaded to and watched on Youtube or Vimeo in HD. ffmpeg – the tool we are going to use – has to be dealt with through the command line. The large number of different parameters and settings which often depend on each other or are mutually exclusive are quite intimidating at first sight (at second as well). Actually it took me quite a while to produce a clip that did not weigh more than 100 MB while keeping a good quality and didn’t produce obscure issues. But in the course of this odyssey I learned the basics of digital videos and also, at the end of the day, the settings which led to my desired outcome even started to make (some) sense!
First of all I created a thousand PNGs (named image000.png, image001.png, …, image999.png) using ggplot2 in R. If you don’t know ggplot2 yet, check out my introductory article on it and the code I used for the article (about stock quote scatter plots changing in time).
Okay, here we go (the new lines are added just for clarity):
-framerate 10 # input frame rate
-i image%03d.png # image names (image000.png, ..., image999.png)
-s:v 1280x720 # video size
-c:v libx264 # encoder
-profile:v high # H.264 profile for video
-crf 20 # constant rate factor
-pix_fmt yuv420p # pixel format
-r 30 # output frame rate
daimler_man.mp4 # clip file name