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

add outputs for width and height rounded to even numbers #167

Closed
wants to merge 2 commits into from

Conversation

dllu
Copy link

@dllu dllu commented Jun 22, 2023

having even number outputs is nice because then you can use -pix_fmt yuv420p with ffmpeg when recording the screen. This results in smaller file sizes and better hardware support.

#!/bin/bash
geometry=$(slop -f "-video_size %mx%n -i $DISPLAY.0+%x,%y")
ffmpeg -y -framerate 60 -f x11grab $geometry -pix_fmt yuv420p "$1"

Otherwise, ffmpeg will complain:

[libx264 @ 0x562cfa9437c0] height not divisible by 2 (52x125)
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

@dllu
Copy link
Author

dllu commented May 14, 2024

ok well I guess for the ffmpeg use case you could just add -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" to the ffmpeg command

@dllu dllu closed this May 14, 2024
@N-R-K
Copy link

N-R-K commented May 14, 2024

Instead of crop you can use pad to pad it out to an even number so that it doesn't discard a row/col that the user selected. It fills the padded area with black pixels.

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

Successfully merging this pull request may close these issues.

None yet

2 participants