Playing h265 HEVC in a JavaFX client

南楼画角 提交于 2019-12-10 22:17:44

问题


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 wich can play the video immediatly from the camera without download the video first to the client. The GoPro has a smal Media Server to get the video over HTTP. as example: http://10.5.5.9:8080/videos/DCIM/100/GPR10973.MP4


回答1:


Native JavaFX Solution

Perhaps this is a duplicate or at least related to:

  • Adding other video codecs / DVD support to JavaFX 2.2.

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.
    • See related: Playing Video in Java FX using vlcj api.
    • Which links to the following project: https://github.com/caprica/vlcj-javafx.
  3. Launch a native video player if you don't need the video embedded.
    • Perhaps Desktop.open() or the Process API could do this.
  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:
    • H.265 support in 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).



来源:https://stackoverflow.com/questions/48511626/playing-h265-hevc-in-a-javafx-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!