From 045bd7e6e711b2fa9efcb90f3777ff4658244333 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Thu, 20 Oct 2022 18:18:26 -0400 Subject: [PATCH] fix: border issue on GIFs where terminal height does not match perfectly with pixel height (rows) --- examples/commands/arrow.gif | 4 ++-- video.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/commands/arrow.gif b/examples/commands/arrow.gif index bea784c00..7f4a544e7 100644 --- a/examples/commands/arrow.gif +++ b/examples/commands/arrow.gif @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f110596f5b6aec43bb7698d707dba464d3843b178610c8815767a4380fea47cf -size 46421 +oid sha256:1245849dac54e0bc8b914b6842b89d4560058cd618089d1a0bb72cb3db29c65c +size 38079 diff --git a/video.go b/video.go index 3aa111583..d32ae72cc 100644 --- a/video.go +++ b/video.go @@ -73,10 +73,11 @@ func MakeGIF(opts VideoOptions) *exec.Cmd { "-framerate", fmt.Sprint(opts.Framerate), "-i", opts.Input+cursorFrameFormat, "-filter_complex", - fmt.Sprintf(`[0][1]overlay[merged];[merged]scale=%d:%d[scaled];[scaled]pad=width=%d:height=%d:x=%d:y=%d[padded];[padded]fillborders=left=%d:right=%d:top=%d:bottom=%d:mode=fixed:color=%s[bordered];[bordered]split[a][b];[a]palettegen=max_colors=256[p];[b][p]paletteuse[out]`, - opts.Width-2*opts.Padding, opts.Height-2*opts.Padding, + fmt.Sprintf(`[0][1]overlay[merged];[merged]scale=%d:-1[scaled];[scaled]pad=%d:%d:(ow-iw)/2:(oh-ih)/2:%s[padded];[padded]fillborders=left=%d:right=%d:top=%d:bottom=%d:mode=fixed:color=%s[bordered];[bordered]split[a][b];[a]palettegen=max_colors=256[p];[b][p]paletteuse[out]`, + opts.Width-2*opts.Padding, opts.Width, opts.Height, - opts.Padding, opts.Padding, opts.Padding, opts.Padding, opts.Padding, opts.Padding, + opts.BackgroundColor, + opts.Padding, opts.Padding, opts.Padding, opts.Padding, opts.BackgroundColor, ), "-map", "[out]",