Skip to content

Instantly share code, notes, and snippets.

@arthurpizza
Last active December 6, 2022 16:04
Show Gist options
  • Save arthurpizza/0a3627879651fe3a711b to your computer and use it in GitHub Desktop.
Save arthurpizza/0a3627879651fe3a711b to your computer and use it in GitHub Desktop.
Video editing cheat sheet

Video Processing with FFMPEG

Intro

Editng and Processing with FFMPEG and Imagemagick is fairly strait forword. Process your clips, concatenate, and compress. You need to make sure all you footage and title cards are the same resolution, framerate, and audio settings. You can convert the files when you first compress them to your working format.

Formats

Lossless Raw Video Format for editing.

ffmpeg -i input.mp4 -vcodec ffv1 -acodec pcm_s16le output.mkv

A good lossy video format that is great for slower computers is Mpeg2.

ffmpeg -y -i final.mkv -vcodec mpeg2video -q 2 -acodec pcm_s16le output.mkv

Connect a list of videos.

First make a list like so:

# this is a comment
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

Then run the concat.

ffmpeg -f concat -i mylist.txt -c copy output

Trim Videos

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

Stablize Video

ffmpeg -y -i input.mp4 -vf deshake=edge=0,crop="in_w-2*16:in_h-2*16",scale=w=1920:h=1080 -vcodec ffv1 -acodec pcm_s16le output.mkv

Extreme Stabizing

ffmpeg -y -i input.mp4 -vf deshake=edge=0:rx=32:ry=32,crop="in_w-2*32:in_h-2*32",scale=w=1920:h=1080 -vcodec ffv1 -acodec pcm_s16le output.mkv

Fade In and Out

ffmpeg -i input.mp4 -vf fade=in:0:30,fade=out:290:320 output.mkv

Title Cards

Make a 4 second silence track for the titles

ffmpeg -f lavfi -i aevalsrc=0:0::duration=4 quiet.wav

Generate an image for the titles. You will need the TTF font in the same working directory.

convert -background black -fill white -font opensans.ttf -size 1920x1080 -pointsize 120 -gravity center label:'Title Here' title.png

This will merge the image and titles to a 4 second clip

ffmpeg -loop 1 -i title.png -i quiet.wav -c:v ffv1 -tune stillimage -c:a pcm_s16le -strict experimental -r 24 -b:a 192k -pix_fmt yuv420p -shortest title.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment