FFMPEG is a command-line video/audio converter which supports lots of codecs and format but also can support some filters (blur, crop, scale, padding, LUT, …). And it’s freaking fast
Why using it ?
I only came across the video filter recently, and i’ll come back to it in future post. But the first/main reason I have been using it was for doing several conversion after render.
I’m rendering After Effects compositions into image sequences through several computers using Autodesk BackBurner and a script I made for it. That let me render the comps much faster.
Yet at the end I must deliver several formats as WMV, MP4, QT Animation, … So instead of creating a new AE project and converting PNG into those new formats, I’m creating 1 job on the renderfarm per format to convert it into. As a all picture, my AE script which send job to Backburner will first send the AE comp to render with after effects, and another job for each format depending of the AE render (this mean those job will wait for the AE render). Those depending jobs will use FFMPEG to convert PNG into the needed file.
Simple conversion :
ffmpeg.exe -i “\\pathToRenderFolder\image_%%5d.png” -r 25 -b:v 5000000 -c:v wmv1 -y “\\pathToRenderFolder\video.wmv”
-i is the input image sequence where %%5d is the number of digit (ie image_00000.png)
-r the frame rate
-b:v the bitrate of your video
-c:v the video codec (in this case windows media video)
-y means to overwrite the video file if it exists already
and then you specify where to save your video file.
Advanced conversion :
As PNG are RGB straight, if it does contain alpha, your RGB might look “weird” to you. Its because you need to premult the RGB with the alpha first.
To do that with FFMPEG we could use the filter graph, and draw the RGB in “overlay” mode.
ffmpeg.exe -i \\pathToRenderFolder\image_%%5d.png” -r 25 -b:v 5000000 -c:v wmv1 -vf “[in] split [T1],fifo, lutrgb=r=0:g=0:b=0, pad=in_w:in_h:0:0:0x000000, [T2] overlay [out]; [T1] fifo, pad=in_w:in_h:0:0:0x000000[T2]” -y “\\pathToRenderFolder\video.wmv”
All the other params are same as above, except for the Video Filter :
-vf will duplicate the video 2 times (split) > we will turn the first video RGB to black and use it as a background (LUT) > we specify that the second video will be draw in Overlay mode (the overlay use the alpha as well) > then we draw the second video.
NB : by changing the LUT and especially the pad color (0xRRGGBB). You can change the background color to whatever you want.