The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Remove Black Borders When Making A GIF In ffmpeg

TODO: Pull subtitle into page object
Code
ffmpeg -i "input.mp4" -t 1 \
-vf cropdetect -f null - 2>&1 | \
awk '/crop/ { print $NF }' | \
tail -1 | xargs -I{} ffmpeg \
-ss 25 -t 9.2 -i "input.mp4" \
-vf "{},fps=11,scale=380:-2:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=52[p];[s1][p]paletteuse" \
-y "output.gif"

Old notes

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

which will give you something like:

Results
crop=2912:1696:52:196

which you use like this:

Code
ffmpeg -ss 0 -i input.mp4 -vf "crop=2912:1696:52:196,fps=30,scale=800:-2:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 -hide_banner -loglevel warning -y output.gif

This works for .webp too - not sure how the color stuff works with it though if it's the best way to do the pallet stuff or not.

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Remove Black Borders When Making A GIF In ffmpeg

This is a one liner that finds the area to crop 
and then does it:

-- code
-- shell

ffmpeg -i "input.mp4" -t 1 \
-vf cropdetect -f null - 2>&1 | \
awk '/crop/ { print $NF }' | \
tail -1 | xargs -I{} ffmpeg \
-ss 25 -t 9.2 -i "input.mp4" \
-vf "{},fps=11,scale=380:-2:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=52[p];[s1][p]paletteuse" \
-y "output.gif"


-- h4

Old notes

-- code
-- shell

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

-- p

which will give you something like: 

-- results

crop=2912:1696:52:196

-- p

which you use like this:

-- code
-- shell

ffmpeg -ss 0 -i input.mp4 -vf "crop=2912:1696:52:196,fps=30,scale=800:-2:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 -hide_banner -loglevel warning -y output.gif

-- note

This works for .webp too - not sure how the color 
stuff works with it though if it's the best way 
to do the pallet stuff or not.

-- categories
-- ffmpeg 
-- Premiere 

-- metadata
-- date: 2021-05-27 14:11:55
-- id: 01f6qgd5
-- site: aws
-- type: post 
-- status: published