Implement video player GUI component #452
Replies: 16 comments
-
Nevermind it's GPL |
Beta Was this translation helpful? Give feedback.
-
Just a note: VLCJ has an incompatible license (GPL). OpenJFX however is compatible (GPL with Classpath Exception) |
Beta Was this translation helpful? Give feedback.
-
It looks like the video player in jcodec's repository is unfinished. It doesn't exist on maven central and has some... interesting method names. |
Beta Was this translation helpful? Give feedback.
-
Hahaha, what the hell😅 |
Beta Was this translation helpful? Give feedback.
-
So I reached out to the developers of vlcj to see if by any chance we could use their product despite incompatible licensing, here's what they said:
So while they are not entirely reluctant to let us use their product, they have legitimate concerns about the legal viability of such an endeavour. It would require a way of us redestributing vlcj while making sure that any derivations of our work would comply with GPL, and I honestly do not see such a way. Does anyone have any expertise on this field? |
Beta Was this translation helpful? Give feedback.
-
GPL was intentionally designed to be incompatible with MIT, so it's not possible. GStreamer seems like the best alternative. This might be helpful: https://github.com/gstreamer-java/gst1-java-examples/blob/master/src/main/java/org/freedesktop/gstreamer/examples/SimpleVideoComponent.java |
Beta Was this translation helpful? Give feedback.
-
I thought so... |
Beta Was this translation helpful? Give feedback.
-
I was able to get something sort of working with GStreamer, but there are many bugs with the GStreamer java bindings. For example, you can't seek to a specific point in the video unless it is playing. And you have to wait ~120 milliseconds after playing before you can seek. Anything more complex than pausing/playing the video doesn't really work at all. My fork is here: https://github.com/Gamebuster19901/litiengine/tree/video Also the fork is largely untested, there may be memory leaks etc. |
Beta Was this translation helpful? Give feedback.
-
Great to hear you've managed to make some progress on this! |
Beta Was this translation helpful? Give feedback.
-
As long as video support is not in the engine, I want to advertise using vlcj in your game (keep licensing in mind). MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory();
EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.mediaPlayers().newEmbeddedMediaPlayer();
mediaPlayer.videoSurface().set(mediaPlayerFactory.videoSurfaces().newVideoSurface(Game.window().getRenderComponent()));
mediaPlayer.media().play("path/to/video.mp4"); |
Beta Was this translation helpful? Give feedback.
-
A bit late in the discussion, but I remember a similar issue had happened with Minecraft's server overlays, namely bukkit, craftbukkit, and spigot. This is only a vague outline from what I remember and requires further investigation, but perhaps a similar approach could work in your case. |
Beta Was this translation helpful? Give feedback.
-
Don't do this, just respect the wishes of the developer(s). Currently, both GStreamer and JavaFX have working implementations and have compatible licenses so there are alternatives. You should only use vlcj if you are fine with licensing your code under the GPL. |
Beta Was this translation helpful? Give feedback.
-
Perhaps we should take a look at https://github.com/bytedeco/javacv. It's licenced under apache so it's compatible. It is a pretty big dependency though, and contains a lot of stuff litiengine doesn't need. |
Beta Was this translation helpful? Give feedback.
-
This looks promising and has a compatible license: https://github.com/bramp/ffmpeg-cli-wrapper I'll see if I can get something working soon. |
Beta Was this translation helpful? Give feedback.
-
looks good indeed! |
Beta Was this translation helpful? Give feedback.
-
Would be cool to have an embedded video player to play the new splash animations. |
Beta Was this translation helpful? Give feedback.
-
Many games play more or less important videos at some point, e.g. for in-game skill showcases, cut scenes, intros, and many more.
So far, we have neither Resource management nor playback capabilities for video files.
With pure java, this is not exactly a trivial thing to do, so we might need to use some external libraries for this.
Potential candidates
JavaFX (GPL)
It is possible to play back video in a JavaFX scene wrapped into a JPanel, but we need to consider this carefully, since JavaFX is not needed anywhere else in the engine right now and LITIengine is an AWT framework by design. Using JavaFX at one point would imply switching other internals such as rendering and UI to JavaFX as well, but that would entail completely changing LITIengine's scope...
Xuggler (LGPL-3.0)
While promising, Xuggler has been deprecated in favor of humble-video.
Humble-Video (AGPL-3.0)
The succesor to Xuggler, but Licensing may be incompatible.
vlcj (GPL 3.0)
A native vlc player instance to be embedded in Java applications.
Java Media Framework (JMF)
Truly an antiquity, the JMF may be a bit dated and lack support for many modern containers and formats. Still, it may be enough for our needs. example 1 example 2
Freedom for Media in Java (FMJ) (LGPL-3.0)
This library addresses some of the shortcomings of the JMF (e.g. codecs and containers), while retaining a fully JMF compatible API.
jcodec (BSD-2-Clause)
An implementation of the most common video and audio codecs.
GStreamer (LGPL-3.0)
Java bindings for GStreamer.
ffmpeg4j (Apache 2.0)
Wrapper to the JNI interface of ffmpeg through JavaCPP. As of 2023-09, this is my favourite solution.
The requirements
Beta Was this translation helpful? Give feedback.
All reactions