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

[Win] 1080x1920 mp4 will not play in media player in java fx all versions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 8, openjfx11
    • Fix Version/s: None
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10, 64 bit, jre 1.8.191 (all versions of java)

      A DESCRIPTION OF THE PROBLEM :
      The MP4 is 1080 x 1920, portrait instead of landscape. It will not play in oracle, nor Azul JavaFX media player. What can you do for us to help us out?

      This may not be a critical bug to some people, but it is to CSG now, because we cannot play video on our new kiosks. Here are a few tickets I’ve found that have been open for years they have not addressed:
      https://bugs.openjdk.java.net/browse/JDK-8133841
      https://bugs.openjdk.java.net/browse/JDK-8091277

      ERROR:
      MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@21ec8c7f] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
      at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
      at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2623)
      at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:692)
      at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:426)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Simply play a 1080x1920 video in portrait mode in java fx media player.

      run the java class below, put a video 1024x1980 in the same directory named largevideo.mp4.

      Email me if you need the largevideo.mp4 and i can send it.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Video would play, but it does not
      ACTUAL -
      Video will not play

      ---------- BEGIN SOURCE ----------

      import javafx.application.Application;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.StackPane;
      import javafx.scene.media.Media;
      import javafx.scene.media.MediaPlayer;
      import javafx.scene.media.MediaView;
      import javafx.stage.Stage;

      public class TestPlayingVideo extends Application {

      private String theMediaURL;
      private Media theMedia;
      private MediaPlayer thePlayer;
      private Button replyButton;

      @Override
      public void start(Stage primaryStage) throws Exception {
      theMediaURL = this.getClass().getResource("largevideo.mp4").toString();
      theMedia = new Media(theMediaURL);

      createPlayer();

      primaryStage.setScene(new Scene(createSceneContent()));
      primaryStage.setTitle("Landscape Video in Portrait mode");
      primaryStage.show();
      }

      private MediaPlayer createPlayer() {
      thePlayer = new MediaPlayer(theMedia);

      thePlayer.setOnReady(() -> {
      int mWidth = theMedia.getWidth();
      int mHeight = theMedia.getHeight();

      System.out.println("Media ready: " + mWidth + "x" + mHeight);
      });

      thePlayer.setOnPlaying(() -> {
      if (replyButton != null) {
      replyButton.setVisible(false);
      }
      });

      thePlayer.setOnEndOfMedia(() -> {
      if (replyButton != null) {
      thePlayer.stop();
      replyButton.setVisible(true);
      }
      });

      thePlayer.setOnError(() -> {
      thePlayer.getError().printStackTrace(System.out);
      System.exit(-1);
      });

      return thePlayer;
      }

      private Parent createSceneContent() {
      int height = 1980; // TODO: get screen resolution
      int width = 1024; // preserve aspect ratio

      MediaView theView = new MediaView(thePlayer);

      // NB: we rotate the media view in order to play
      // a landscape video as a portrait
      theView.setFitHeight(width);
      theView.setFitWidth(height);
      // theView.setRotate(-90);

      replyButton = new Button("Replay the video");

      replyButton.setOnAction((event) -> {
      if (thePlayer != null) {
      MediaPlayer.Status status = thePlayer.getStatus();
      if ((status == MediaPlayer.Status.UNKNOWN) || (status == MediaPlayer.Status.HALTED)) {
      return;
      }
      if ((status == MediaPlayer.Status.PAUSED) || (status == MediaPlayer.Status.STOPPED)
      || (status == MediaPlayer.Status.READY)) {
      thePlayer.play();
      }
      }
      });

      StackPane root = new StackPane();
      root.setMaxSize(width, height);
      root.setMinSize(width, height);

      root.getChildren().addAll(theView, replyButton);

      return root;
      }

      public static void main(String[] args) throws Exception {
      launch(args);
      }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pmangal Priyanka Mangal
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: