Мы разрабатываем приложение для потоковой передачи видео с использованием JavaFx и JavaCv. Во время воспроизведения Stream в gridPane (8X8) мы иногда сталкиваемся с выплескивающейся проблемой белого экрана, и эта проблема продолжается.Подробности: -
new Thread(new Runnable() {
@Override
public void run() {
frameGrabber = new FFmpegFrameGrabber(Url);
frameGrabber.setVideoOption("preset","ultrafast");
frameGrabber.setOption("rtsp_transport","tcp");
frameGrabber.setOption("stimeout" , "60000");
frameGrabber.setAudioChannels(0);
frameGrabber.setAudioCodec(0);
try {
frameGrabber.start();
} catch (Exception e) {
e.printStackTrace();
}
JavaFXFrameConverter jconverter=new JavaFXFrameConverter();//converting frame to javafx Image
while(true){
try {
Frame frame = frameGrabber.grab();
frame.clone();
if(frame.image!=null){
updateUi(im,jconverter.convert(frame));//im->ImageView
}
} catch (FrameGrabber.Exception e) {
}
}
}
}
}).start();
//updateui explanation
updateUi(ImageView im,Image image){
Platform.runLater(new Runnable() {
@Override
public void run() {
im.setImage(image);//here i m updating imageview
}
});
}
мы не получаем никаких исключений в jdk-8, но в jdk-9 мы получаем следующее исключение. Но я не уверен, связано ли это с проблемой белого экрана.
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index -1 out-of-bounds for length 764
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:440)
at javafx.graphics/javafx.scene.Parent.updateCachedBounds(Parent.java:1723)
at javafx.graphics/javafx.scene.Parent.recomputeBounds(Parent.java:1667)
at javafx.graphics/javafx.scene.Parent.doComputeGeomBounds(Parent.java:1520)
at javafx.graphics/javafx.scene.Parent.access$200(Parent.java:81)
at javafx.graphics/javafx.scene.Parent$1.doComputeGeomBounds(Parent.java:117)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.computeGeomBoundsImpl(ParentHelper.java:86)
at javafx.graphics/com.sun.javafx.scene.layout.RegionHelper.superComputeGeomBoundsImpl(RegionHelper.java:78)
at javafx.graphics/com.sun.javafx.scene.layout.RegionHelper.superComputeGeomBounds(RegionHelper.java:62)
at javafx.graphics/javafx.scene.layout.Region.doComputeGeomBounds(Region.java:3291)
at javafx.graphics/javafx.scene.layout.Region.access$300(Region.java:149)
at javafx.graphics/javafx.scene.layout.Region$1.doComputeGeomBounds(Region.java:170)
at javafx.graphics/com.sun.javafx.scene.layout.RegionHelper.computeGeomBoundsImpl(RegionHelper.java:89)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.computeGeomBounds(NodeHelper.java:117)
at javafx.graphics/javafx.scene.Node.updateGeomBounds(Node.java:3831)
at javafx.graphics/javafx.scene.Node.getGeomBounds(Node.java:3793)
at javafx.graphics/javafx.scene.Node.getLocalBounds(Node.java:3741)
at javafx.graphics/javafx.scene.Node.updateTxBounds(Node.java:3895)
at javafx.graphics/javafx.scene.Node.getTransformedBounds(Node.java:3687)
at javafx.graphics/javafx.scene.Node.updateBounds(Node.java:766)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1851)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Parent.updateBounds(Parent.java:1849)
at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2522)
at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:410)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:409)
at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:436)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:518)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:319)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175)
at java.base/java.lang.Thread.run(Thread.java:844)