Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions demos/video-capture-simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ def main() -> None:
# the video, as well as possibly audio and more. These are each called "streams". We only create one
# stream here, since we're just recording video.
video_stream = avmux.add_stream(CODEC, rate=FPS, options=CODEC_OPTIONS)
video_stream.width = monitor["width"]
video_stream.height = monitor["height"]
# Width and height must be divisible by 2, otherwise the encoder will fail.
# Round down to the nearest even number.
video_stream.width = monitor["width"] // 2 * 2
video_stream.height = monitor["height"] // 2 * 2
# There are more options you can set on the video stream; the full demo uses some of those.

# Count how many frames we're capturing, so we can log the FPS later.
Expand Down
6 changes: 4 additions & 2 deletions demos/video-capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,10 @@ def main() -> None:
# so some video encoders will tag it as AVCOL_TRC_BT709 (1) instead.
video_stream.color_trc = 13

video_stream.width = monitor["width"]
video_stream.height = monitor["height"]
# Width and height must be divisible by 2, otherwise the encoder will fail.
# Round down to the nearest even number.
video_stream.width = monitor["width"] // 2 * 2
video_stream.height = monitor["height"] // 2 * 2
# There are multiple time bases in play (stream, codec context, per-frame). Depending on the container
# and codec, some of these might be ignored or overridden. We set the desired time base consistently
# everywhere, so that the saved timestamps are correct regardless of what format we're saving to.
Expand Down