FFMPEG Snippet Collection

FFMPEG is an extremely powerful tool for converting and editing video material. Not only is it ideal for converting to a wide variety of formats, it can also merge image data into video, crop, add filters and even export gif files.

For my own work I can’t imagine my work without this tool. However, the obstacles for getting started are relatively high, because the installation is more or less difficult depending on the operating system. Furthermore, you work with FFMPEG in the command line, which is a daunting task for some people.

I find the technology so helpful because I have to formulate every action with code so that I can reuse it at any time. That saves a lot of work at some point.

In this article I collect FFMPEG snippets that I find especially useful for my work as a designer and creative coder.

An example file-conversion with FFMPEG

Convert one video-format to another

ffmpeg -i in.mov out.mp4

Cut the first 30 seconds of a video

ffmpeg -ss 00:00:30.0 -i input.wmv -c copy -t 00:00:10.0 output.wmv

Merge Audio and Video

ffmpeg -i in.mp4 -i in.wav -c:v copy -c:a aac -shortest output.mp4

Compress Audio

ffmpeg -i input.mp4 -filter_complex "compand=attacks=0:points=-80/-900|-45/-15|-27/-9|-5/-5|20/20" output.mp4

Create images from video

ffmpeg -i input.mp4 -vf fps=1/1 ./thumbs/video%03d.jpg

Concatenate Videos

ffmpeg -i ./input1.mp4 \
	   -i ./input2.mp4 \
       -filter_complex "[0:v] [0:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" \
       -map "[v]" -map "[a]" ./output.mp4

Add padding / white letterbox

ffmpeg -i input.mp4 -vf "pad=width=900:height=900:x=157:y=45:color=white" output.mp4

Convert video to gif

ffmpeg -i input.mp4 -f gif output.gif

ffmpeg -i input.mp4 -filter_complex "[0:v] palettegen" palette.png

ffmpeg -i input.mp4 -i palette.png -filter_complex "[0:v][1:v] paletteuse" output.gif

ffmpeg -i input.mp4 -filter_complex "[0:v] fps=15,scale=500:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" output.gif

Desaturate Video

ffmpeg -i input -vf hue=s=0 output

Published by Tim on Saturday November 21, 2020

Last modified on February 17th, 2021 at 15:50


Related

3 Tips to accelerate and optimize your learning process

Tips

The Infinite Layout Machine

Student Work

Processing Community Day 2021 – the recordings

Community Talks

PCD2021 – Q&A with Casey Reas

Community Talks

PCD2021 – Vera van de Seyp

Community Talks

Two Perspectives – Episode 3

Podcast

Processing-Tutorial: A Grid of Arcs

Tutorials

Processing-Tutorial: Exploring Wave-Figures

Tutorials

Interactive Grid System (Livestream)

Tutorials

The Hidden Benefits of Learning to Code

Philosophy Stories Writings

Talking at Zuibishe / China

Talks

Creative Coding Manifesto 2021

Films Philosophy Stories Writings

Out now: Typemachines

Future Plans

My Story (part 2 – told at Taaalks Conference 2020)

Stories Talks

New Course: Bauhaus Coding Workshop

Learnings from the Bauhaus about Art and Technology

Writings

TypeMachines – A workshop at écal Lausanne

Interview with Tech+Art Podcast

Interviews

My Story (Part 1)

Stories Writings

Processing-Tutorial: Rasterize 3D

Tutorials

Alpha-Release: “Creative Coding Essentials”

Processing-Tutorial: Image-Rasterizer

Tutorials

p5studio

Projects

Lifeline

Projects

Processing-Tutorial: Kinetic Typography 1

Tutorials

My 10 favorite Processing-libraries

4 alternative, free and well-curated resources for images, fonts and data

Writings

Processing or p5.js? My opinions

Programming Posters

Projects

The Bach-Project

Projects

Random Composition

Sessions

New Course: Copy and Paste

Building a Poster Design Tool

Sessions

Random Collage Generator

Sessions

The Wave

Sessions

TEDx UniPaderborn: Creative Coding as a tool for Digital Empowerment

Films Philosophy Stories Talks

PCD2021 – Sander Sturing

Community Talks

PCD2021 – Dr. Martin Lorenz

Community Talks

PCD2021 – Patrik Hübner

Community Talks

My talk at Two Times Elliott

Talks

Essential tips for students when learning to code

Stories Tips Writings

Chatting with COPE Studio