2

Currently I’m trying to develop RTSP video player, which can show many streams at one time (2, 4, 5 etc). It has to be fast and be able to run on Windows, Mac and Linux.

First app version has been written on Swing and VLC. Good performance, ability to play many streams at one time on slow PC. But not impressive UI and video playing is unsupported on Mac

So, after a lot of researching I stopped on JavaFX and VLC. Great UI, support on all platforms, but performance issues on slow PCs.

Here is simple project which can play one video: https://github.com/costello/vpfx
(don’t forget to set your media link in class java/app/AppController.java, line 22)

Unfortunately it’s using too much CPU, even if I play only one video. I tried to play 2 or 4 videos (from different RTSP streams), completely nightmare.

Here is CPU usage graph on PC with Intel® Pentium® Processor E5300 
(2M Cache, 2.60 GHz, 800 MHz FSB) and integrated video card: https://i.sstatic.net/kVzIq.jpg

vlcj version: 3.0.1 
VLC version: 2.1.5
Java: 7 and 8 (java fx 2.2 and java fx 8), same result.

Found this OpenGL discussion: How to use OpenGL in JavaFX?

But I don’t know how to use OpenGL to render image from given RGB array and even I don’t know will it help.

8
  • You really need to make sure you are rendering using hardware acceleration, but even then there is a limit to how much resource is available to do that - even if you can hardware accelerate one stream, doing it for five may be impossible. Also, your implementation is prone to corrupt video memory because of your use of Platform.runLater in your render code (you access the native video buffer in an unsynchronised way). vlcj + JavaFX8 is a difficult problem. Commented Aug 8, 2014 at 17:50
  • I use a Swing app for vlcj, with my JavaFX components (e.g. menus) hosted inside a JFXPanel. Not ideal. Commented Aug 8, 2014 at 17:53
  • @caprica What about Mac support in your solution? Commented Aug 8, 2014 at 22:49
  • Mac support on Jdk7+ is also difficult, you have to render the video yourself (again, find a way to hardware accelerate it), but at least you won't have a synchronisation problem. And yet again, doing five streams that way (in hardware) is likely unfeasible. Commented Aug 9, 2014 at 6:45
  • 1
    @Victor nice to hear that! It looks like you have memory leak, I had this as well. Switching to Swing solved everything, but you can try jProfiler or VisualVM to investigate memory, can be very useful. Commented Mar 23, 2019 at 21:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.