Conversation
Some encoders (e.g., x264enc used by the MP4 and Matroska profiles) require even resolution, but streams without area selection (e.g., a window capture) may have odd dimensions, failing with "Can not initialize x264 encoder". The even rounding previously only existed in the select-area path. When the combined stream size is odd or unknown, insert a videoscale restricted to even stepped caps so it follows the negotiated size and rounds down to even. Streams known to be even are linked directly as before. The combined size of multiple streams is the sum of widths and the maximum height, matching how they are stacked horizontally. The stepped range maximum must be well below i32::MAX, as larger values overflow videoscale's internal aspect-ratio arithmetic. Fixes SeaDve#357
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #357
Problem
Recording with the MP4 or Matroska profile fails with
Can not initialize x264 encoderwhen the captured stream has an odd width or height — typical for window captures. The pipeline log shows the underlying cause:x264 requires even dimensions, but the even rounding previously only existed in the select-area path (
videoscale+videocrop). Captures without a selection linked the stream directly to the encoder queue.Fix
When there is no area selection and the combined stream size is odd or unknown, insert a
videoscalerestricted to even stepped caps (width/height = [2, 65536, 2]). This wayvideoscalefollows the actually negotiated size (aftervideoflip/compositor) and rounds down to even, instead of relying on portal metadata that may be missing or disagree with the buffers. Streams known to be even are linked directly, as before.The combined size of multiple streams is computed as the sum of widths and the maximum height, matching how they are stacked horizontally by the compositor.
The stepped range maximum is 65536 rather than
i32::MAXbecause larger values overflow videoscale's internal aspect-ratio arithmetic, producing empty ([0, 0]) caps during negotiation.Verification
gst-launchcheck:1365x717input with the stepped caps negotiates to1364x716; even input passes through unscaled.cargo fmt --checkandcargo clippy -- -D warningsare clean.cargo testpasses except for 5 failures (i18n,profile,settingstests) that also fail on unmodifiedmainin this environment (missing installed gresource, should-panic behavior).