Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ffmpeg cheat sheet

base encode to H265 (HEVC)

ffmpeg -i in.mts -c:a copy -c:v libx265 out.mp4

base encode to H264

ffmpeg -i in.mts -c:a copy -c:v h264 out.mp4

scale to 720p

-s 1280x720

compress better

-preset veryslow

convert audio to aac

-c:a aac -b:a 384k -strict -2

specify bitrate

-b:v 4000k

specify quality (default 23 for H264, 28 for H265, lower is better)

-crf 20

change framerate

-r 25

keep subtitles

-c:s mov_text

drop duplicated frames and interpolate framerate

-vf mpdecimate,minterpolate=fps=25

crop (add :x:y for position)

-filter:v "crop=1280:720"

truncate (-ss for start time, -t for end time, format: [[hh:]mm:]ss[.msec])

-ss 21 -t 42

rotate (1 = 90Clockwise, 2 = 90CounterClockwise)

-vf "transpose=1"

change image brightness

-vf "lutyuv=y=val*1.3"
-filter:v lutyuv="y=gammaval(0.8)"

audio highpass filter

-af "highpass=f=80"

audio compression filter

-af "compand"

audio right channel only + highpass (reduce clicks) + noise reduction + compression + variable bitrate (for ATC recordings)

-af "pan=mono|c0=FR,highpass=200,afftdn=nf=-30,compand" -q:a 1
find . -type f -name '*[0-9].MP3' -exec bash -c 'ffmpeg -i "$0" -af "pan=mono|c0=FR,highpass=200,afftdn=nf=-30,compand" -q:a 1 "${0/%.MP3/_mono.mp3}"' '{}' \;

two pass

-b:v 4000k -pass 1 -f mkv /dev/null
-b:v 4000k -pass 2 out.mkv

convert all files

for f in *.mov; do avconv -i "$f" -c:a aac -b:a 384k -strict -2 -c:v h264 "${}.mp4"; done

batch convert WAV to mp3

find . -type f -name '*.WAV' -exec bash -c 'ffmpeg -i "$0" -y -c:a libmp3lame -q:a 0 "${0/%WAV/mp3}"' '{}' \;

batch convert to high quality H265

find . -type f -name '* (upscaled).mp4' -exec bash -c 'ffmpeg -i "$0" -c:a copy -c:v libx265 -crf 18 "${0/%).mp4/) h265.mp4}"' '{}' \;

batch update file time from metadata (works for pictures and videos)

exiftool "-filemodifydate<datetimeoriginal" *.mp4 (WYSIWYG login with google)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment