Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg struggles converting gifs with odd dimensions #142

Open
JamesLMilner opened this issue Jun 27, 2022 · 0 comments
Open

ffmpeg struggles converting gifs with odd dimensions #142

JamesLMilner opened this issue Jun 27, 2022 · 0 comments

Comments

@JamesLMilner
Copy link

Hey! Firstly, thanks for the great project.

I am noticing an issue with odd shaped gifs :

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] > Having trouble writing template: _site/posts/cancelling-requests/index.html

`TemplateWriterWriteError` was thrown
[11ty] > Failed executing '/home/james/Code/jameslmilner.com-11ty/node_modules/ffmpeg-static/ffmpeg' -y -v error -i '_site/img/posts/abort/abortable-fetch.gif' -filter_complex '[0:v] fps=15, scale=iw:-2' -vsync 0 -f mp4 -pix_fmt yuv420p '_site/img/posts/abort/abortable-fetch.mp4' with [libx264 @ 0x6970fc0] width not divisible by 2 (1203x492)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

`Error` was thrown:
[11ty]     Error: Failed executing '/home/james/Code/jameslmilner.com-11ty/node_modules/ffmpeg-static/ffmpeg' -y -v error -i '_site/img/posts/abort/abortable-fetch.gif' -filter_complex '[0:v] fps=15, scale=iw:-2' -vsync 0 -f mp4 -pix_fmt yuv420p '_site/img/posts/abort/abortable-fetch.mp4' with [libx264 @ 0x6970fc0] width not divisible by 2 (1203x492)
    Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

If I change

"[0:v] fps=15, scale=iw:-2",

to:

    "[0:v] fps=15, scale=trunc(iw/2)*2:trunc(ih/2)*2",

It removes the errors, but I think that doesn't perform any scaling as was originally intended. I could look at the correct rounding logic to figure out how to keep the -2 scaling and raise a PR if it would be helpful. Let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant