Skip to content

Demo video-capture width and height must be divisible by 2#472

Open
sjoerdsmink wants to merge 3 commits intoBoboTiG:mainfrom
sjoerdsmink:patch-2
Open

Demo video-capture width and height must be divisible by 2#472
sjoerdsmink wants to merge 3 commits intoBoboTiG:mainfrom
sjoerdsmink:patch-2

Conversation

@sjoerdsmink
Copy link
Contributor

When the resolution is not an even number, it generates an error:

 File "av/codec/context.pyx", line 200, in av.codec.context.CodecContext.open                                                                                                                           
    File "av/codec/context.pyx", line 220, in av.codec.context.CodecContext.open                                                                                                                           
    File "av/error.pyx", line 424, in av.error.err_check                                                                                                                                                   
  av.error.ExternalError: [Errno 542398533] Generic error in an external library: 'avcodec_open2(libx264)'; last error log: [libx264] height not divisible by 2 (1512x949)

Changes proposed in this PR

Fixes #
Width and height must be divisible by 2, otherwise the encoder will fail. Round down to the nearest even number.

  • Tests added/updated
  • Documentation updated
  • Changelog entry added
  • ./check.sh passed

Width and height must be divisible by 2, otherwise the encoder will fail. Round down to the nearest even number.
Width and height must be divisible by 2, otherwise the encoder will fail. Round down to the nearest even number.
@BoboTiG
Copy link
Owner

BoboTiG commented Feb 6, 2026

/cc @jholveck

@jholveck
Copy link
Contributor

jholveck commented Feb 6, 2026

I would suggest changing the capture resolution too; not sure what the libraries will do if they don't match, but making them match is probably best.

In the non-simple demo, I would also conditionalize this on the codec being libx264: not all codecs have this limitation (I just tested on h264_nvenc).

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.

3 participants