简体   繁体   中英

JavaFX MediaPlayer exceptions in Debian Linux

I'm having issues (like some others) with getting the JavaFX MediaPlayer component to play content (video/audio files of any container/encoding type) in Debian Jessie. I've tried and exhausted any potential solution to this problem (I have GLIB 2.28 installed, I've upgraded Java to u60, I've ensured all codec packages have been installed including libavcodec/libavformat/libavutil/etc., I'm at gtk2 2.18+). I don't know what else to do or try. I have a very simple application that works perfectly fine under Windows 7 .

Here is the simple application:

public class MediaTest extends Application {

    @Override
    public void start(Stage primaryStage) {
        BorderPane root = new BorderPane();

        Media media = new Media(new File("/path/to/file/test.flv").toURI().toString());
        MediaPlayer player = new MediaPlayer(media);
        MediaView view = new MediaView(player);

        root.setCenter(view);

        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("For the love of God, please work");
        primaryStage.setScene(scene);
        primaryStage.show();

        player.play();
    }

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

The problem manifests on the creation of the MediaPlayer. After a few lengthy debugging sessions, I found that the exception that is internally generated is some permutation of MEDIA_UNSUPPORTED message, regardless of the media type or format , though the Exception that is caught lists it as

MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player!

I've tried just about everything I can think of. I have a sample video file encoded just about every way possible, and in a myriad of different containers. Nothing works. I have a sample audio file encoded in just about every way possible, with the same results.

Am I just SOL on getting MediaPlayer to work on Debian? If so, this is highly disappointing. I know it's nigh impossible to get something to work on Windows, Mac, and every distro of Linux, but Write Once Run Everywhere seems not to hold true for Java8.

EDIT: I have oracle's java8, not openjdk.


EDIT 2: The internal error seems to be coming from gstreamer. Here are the args going into MediaException.getMediaException(Object source, int errorCode, String message) :

source    : com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMedia
errorCode : 265
message   : ERROR_MEDIA_AUDIO_FORMAT_UNSUPPORTED

Mind the graphics drivers. For example, in Ubuntu 16.04, the AMD opensource graphics drivers seem incomplete, javafx video seems impossible.

I got it to work in this environment: Ubuntu 14.04, intel chipset graphics, oracle jdk 8. Installed libavcodec54 and libavformat54. Not it works (Graphics and sound OK). My test video: http://www.sample-videos.com/video/flv/720/big_buck_bunny_720p_1mb.flv (container: MP4/M4a, video: H.264, sound: MPEG-4 AAC)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM