Is it possible to autocrop black borders of a video with ffmpeg?

Yes, it is possible.

First play your video to see if it is OK:

ffplay -i YourMovie.mp4 -vf "cropdetect=24:16:0"

The cropdetect filter values are:

cropdetect=limit:round:reset

limit = black threshold (default 24)
round = output resolution must be divisible to this
reset = after how many frames the detection process will start over

If it looks OK, crop it:

ffmpeg -i YourMovie.mp4 -vf "crop=640:256:0:36" YourCroppedMovie.mp4

Source and more info: René Calles blog renevolution.com


From: https://stackoverflow.com/questions/17265381/ffmpeg-get-value-from-cropdetect

ffmpeg -i input -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1

Putting the other two answers together into a script:

#!/bin/sh
#ffmpeg_zoom ver 20180128202453
I="$@";X=${I##*.};O=${I%.*}_zoomed.${X};f=$(which ffmpeg 2>/dev/null)
if [ ! "$f" ]||[ "$f" = '' ];then echo "Install ffmpeg";exit 1;fi
C=$($f -i "$I" -t 1 -vf cropdetect -f null - 2>&1|awk '/crop/{print $NF}'|tail -n1)
echo $f -i "$I" -vf "$C" "$O"; $f -i "$I" -vf "$C" "$O"

This question has some relevant ffmpeg examples