Skip to content

GStreamer on Windows: make the preview's frame size follow its widget - #376

Draft
youms wants to merge 2 commits into
Cimbali:mainfrom
youms:fix/gst-dynamic-preview
Draft

youms wants to merge 2 commits into
Cimbali:mainfrom
youms:fix/gst-dynamic-preview

Conversation

@youms

@youms youms commented Oct 28, 2026 •

Copy link
Copy Markdown

Refs #365. Builds on #370: the first of the two commits in this branch is the commit of that PR, and the change here is the second. It stays a draft until #370 is merged, then I will rebase it so only that commit remains.

With the GPU scaling of #370 the frame size is fixed when playback starts. A preview that starts in a small window and is maximized afterwards is stretched, so its text is blurry. The same goes for a paused frame and for the last frame held at the end of a clip.

Now the frame size grows with the video widget:

  • The target is the widget's size in device pixels, at the clip's aspect ratio and capped at the clip's size.
  • It is updated 250 ms after the last resize, when it exceeds the current frame by more than 5 %.
  • It never shrinks while playing, because shrinking the caps of a playing gtksink can freeze it (gst-plugins-good work item 1082).
  • When paused or ended, changing the caps produces no new buffer, so a flush seek to the current position makes d3d11convert deliver one at the new size. The position is kept 5 ms inside the clip, because a seek to the very end decodes no frame.

Changes media_overlays/gst_backend.py only.

Tested on Windows 11, MSYS2 UCRT64, Python 3.14.9, GTK 3.24.52, GStreamer 1.28.8, Intel UHD 620, in the real app. After maximizing the presenter window, the preview text is blocky with #370 alone and clear with this branch, while playing, paused and on a held last frame.

#373 and this PR both change __init__ and update_gpu_target() in gst_backend.py, but git merges them without a conflict. Whichever merges second only needs the shared #370 commit dropped.

Not tested: other GPUs.

youms added 2 commits October 28, 2026 14:15
With the GPU scaling of the previous commit the frame size is fixed when
playback starts. A preview that starts in a small window and is maximized
afterwards is then stretched (blurry text), and so is a paused frame or the
last frame held at the end of a clip.

Let the size grow with the widget. Shrinking the caps of a playing gtksink
is avoided on purpose (it can freeze, see gst-plugins-good work item 1082),
so the frame only gets bigger:

- the target is the video widget's allocation in device pixels at the
  clip's aspect ratio, capped at the clip's own size;
- when the allocation exceeds the current frame by more than 5 %, the
  capsfilter is updated after 250 ms without a further resize;
- when the pipeline is paused or the clip has ended, the caps change alone
  produces no new buffer, so a flush seek to the current position (kept
  5 ms inside the clip: a seek to the very end decodes no frame) makes
  d3d11convert deliver one at the new size.

Builds on Cimbali#365.

This branch has not been deployed

No deployments
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.

1 participant