gstreamer-java / gst1-java-swing

Swing integration for GStreamer and gst1-java-core
GNU Lesser General Public License v3.0
5 stars 1 forks source link

Video unscaled in GstVideoComponent until revalidate #2

Closed orlovsn closed 2 years ago

orlovsn commented 2 years ago

I'm using SwingPlayer example code to render rtsp and hls streams (1080+ resolution) on smaller (like 640x480) jpanels Problem - when GstVideoComponent starts to render video, it is unscaled (so I see 640x480 crop from full 1080 frame) until jpanel is resized and GstVideoComponent gets new prefferedSize
When I switch source with

playbin.stop();
playbin.setURI(new URI(url));
playbin.play();

it is also unscaled, even if jpanel was resized/revalidated before (with previous url)

Workaround - I currently use full revalidate + setPreferredSize with parent's width and height after every source change in Bus.ASYNC_DONE event:

vc.revalidate(); // vc = GstVideoComponent 
revalidate(); // parent JPanel
vc.setPreferredSize(new Dimension(getWidth(), getHeight());

Is it normal or there is some better approach not covered in SwingPlayer example?
gstreamer latest release, windows 11

neilcsmith-net commented 2 years ago

What is your component hierarchy? What layout manager? Is it in a JScrollPane?

orlovsn commented 2 years ago

GstVideoComponent in Center of BorderLayout of JPanel that is context for JFrame, without scroll
Looks like problem was with windows 11+JDK8 (x86 jvm) on mine Lenovo P17G1 with 1080 screen - can't reproduce it with JDK11 and on another PCs with w11+JDK11/JDK17 (amd64 jvm) or Debian11 + JDK11/JDK17 (amd64 jvm)