Playing h265 HEVC in a JavaFX client
Asked Answered
J

1

2

I had a small JavaFX application to play some GoPro videos on a Windows / Linux client. In the past I had using a GoPro 4. I've downloaded the video to the client and play it from the local storage. Like this:

    File file = new File("AnyVideo.MP4");
    Media m = new Media(file.toURI().toString());
    MediaPlayer mp = new MediaPlayer(m);
    mp.setAutoPlay(true);
    mediaView.setMediaPlayer(mp);

I'll try to switch to the new GoPro 6 now. But it doesn't worked as expected.

The problem is probably that the JavaFX MediaPlayer did not support the codec from the new GoPro 6.

  • GoPro 4: h264 AVC video codec
  • GoPro 6: h265 HEVC video codec

The JavaFX MediaPlayer supports only the h264 codec.

Did anyone know a way how I can play a h265 HEVC video with my JavaFX application. In the best case a solution which can play the video immediately from the camera without download the video first to the client. The GoPro has a small Media Server to get the video over HTTP. as example: http://10.5.5.9:8080/videos/DCIM/100/GPR10973.MP4

Janina answered 29/1, 2018 at 23:23 Comment(0)
L
3

Native JavaFX Solution

Perhaps this is a duplicate or at least related to:

See my answer to that question for links to related feature requests in the JavaFX bug tracker system.

Solutions using non-JavaFX tech from JavaFX

There are other solutions than those discussed in answers to that question which may work for you. Especially if your primary concern is just getting some kind of playback, even if it doesn't have deep integration with the JavaFX media system.

For instance, other approaches than native JavaFX playback could be:

  1. Using VLCJ with some kind of Swing integration (such as a SwingNode, though that may or may not work).
  2. Rendering the VLCJ video into a JavaFX ImageView or Canvas.
  3. Launch a native video player if you don't need the video embedded.
  4. Call ffmpeg to convert h265 to h264.
    • I don't know much about this, but a quick google of the topic shows up references to the xuggle project.
    • Current status of the xuggler project is:

      Xuggler is on hiatus as no one is actively developing it anymore. Sorry. That said, you can always find the source code and start hacking yourself. Good luck!

    • So I wish you good luck with that ;-)
  5. Launching the native browser through a HostServices.showDocument() call to display the video.
  6. Use a third party browsing component that can be integrated into JavaFX and includes support for the media type you want to play back, for example JxBrowser:

Of the options outlined above, personally, I would recommend using HostServices to play the video in the native browser if that kind of solution will possibly work for you.

Going into detail on various options is probably out of scope for StackOverflow (even the above list starts looking like a sometimes frowned upon library recommendation).

Lordsandladies answered 30/1, 2018 at 0:19 Comment(1)
I was going to post an answer, but I'm not sure I could add much to here - a good summary of the sensible options. FWIW though, if you're just using ffmpeg to convert the video, you'd probably be better off using something like the FFMPEG CLI wrapper (github.com/bramp/ffmpeg-cli-wrapper). It doesn't allow the sort of fine-grained control that Xuggler does, but is probably more suitable for just converting a file in one hit.Hokkaido

© 2022 - 2024 — McMap. All rights reserved.