Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8283318

Videos with unusual sizes cannot be played on windows

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10 21H1, JDK jdk-17.0.2 x64, JFX 17.0.2

      A DESCRIPTION OF THE PROBLEM :
      Some of the screen capture videos which we produce cannot be played in JavaFX-based players on windows. The issue appears to depend on the video size. Since we are recording screen capture, we cannot pick a "nice and clean" video size, it has to match the screen resolution.

      I have tracked it down to a handler for a recoverable DirectShow error in modules/javafx.media/src/main/native/gstreamer/plugins/dshowwrapper/dshowwrapper.cpp. That handler is enabled only "if ((width < height) || (width > 1920 && height > 1080))", but we seem to require it for smaller and non-portrait videos too. I have built my own version of JavaFX module where the handler was always enabled, which has resolved the problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Play the video at
      <link>
      with any JavaFX player, eg. the simplistic one attached here.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The window opens and the video is played back inside it.
      ACTUAL -
      No errors, but no video either, just a blank window.

      ---------- BEGIN SOURCE ----------
      import java.io.File;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      import javafx.beans.binding.Bindings;
      import javafx.beans.property.DoubleProperty;
      import javafx.scene.media.Media;
      import javafx.scene.media.MediaPlayer;
      import javafx.scene.media.MediaView;

      public class FXPlayer extends Application {

          @Override
          public void start(Stage stage) {
              File videoFile = new File( FXPlayer.args[0] );


              MediaView mediaView = new MediaView();
              DoubleProperty width = mediaView.fitWidthProperty();
              DoubleProperty height = mediaView.fitHeightProperty();
              width.bind( Bindings.selectDouble( mediaView.sceneProperty(), "width" ) );
              height.bind( Bindings.selectDouble( mediaView.sceneProperty(), "height" ) );
              mediaView.setPreserveRatio( true );

              MediaPlayer mediaPlayer = new MediaPlayer( new Media( videoFile.toURI().toString() ) );
              mediaPlayer.setMute( true );
              mediaView.setMediaPlayer( mediaPlayer );
              mediaPlayer.play();

              StackPane root = new StackPane();
              root.getChildren().add( mediaView );
              
              Scene scene = new Scene(root, 640, 480);
              stage.setScene(scene);
              stage.show();
          }

          private static String[] args;
          
          public static void main(String[] args) {
              if ( args.length < 1 ) {
                  return;
              }
              FXPlayer.args = args;
              launch();
          }

      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

        1. From_submitter.mp4
          158 kB
        2. FXPlayer.java
          2 kB
        3. notepad_capture_1900x1088.mp4
          159 kB
        4. notepad_capture_1902x1090.mp4
          162 kB
        5. one_video.mp4
          112 kB
        6. two_video.mp4
          294 kB

          Issue Links

            Activity

              People

              Assignee:
              almatvee Alexander Matveev
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: