home ~ projects ~ socials

Bluesky ffmpeg mp4 Cropping And Muting Command

This is the ffmpeg command I use to process mp4s for posting on Bluesky1. It removes any black bars2 and removes the audio.

INPUT_PATH="/Users/alan/GIFs/factory/Johnny Mnemonic/mp4s/raw/jonny-mnemonic-getting-ready.mp4"
OUTPUT_PATH="/Users/alan/GIFs/factory/Johnny Mnemonic/mp4s/cropped/jonny-mnemonic-getting-ready.mp4"

ffmpeg -i "${INPUT_PATH}" -ss 0.1 \
-t 0.1 -vf cropdetect=limit=2 -f null - 2>&1 | \
awk '/crop/ { print $NF }' | \
tail -1 | xargs -I{CROP} \
ffmpeg -loglevel error -hide_banner \
-i "${INPUT_PATH}" \
-vf "{CROP}" -an -y "${OUTPUT_PATH}"
Output:
-- end of line --

Endnotes

The cropdetect=limit=2 sets the threshold for what's considered a black bar. The default is 24, but I bump it to 2 generally. If you get a crop that isn't right it's the setting to play with

Footnotes

If you want to follow me there

Cropping With DaVinci Resolve

I generally crop in to different parts of a frame when making clips in DaVinci Resolve. This results in black bars replacing the areas I cropped out.