Is there a media player library for JVM desktop wi...
# compose-desktop
s
Is there a media player library for JVM desktop with a license suitable for commercial use (Apache 2, MIT, BSD)? https://github.com/caprica/vlcj seems to be a popular choice, but the problem is that it ultimately needs VLC, which is GPL.
u
s
The library is GPL ... That's unfortunately not suitable for a commercial app.
u
https://github.com/KhubaibKhan4/MediaPlayer-KMP/blob/master/mediaplayer-kmp/src/jvmMain/kotlin/DesktopWebView.kt it's only this,I think you have the right to be inspired to make your own implementation.
e
even if you're using ffmpeg directly, you're likely going to need libx264 and libx265 which are GPL
if you really need to avoid GPL, your best bet is likely to use system libraries
s
Yes, I think so. What Kotlin libraries exist that use system libraries under the hood?
Decoding should work with openh264 under BSD, so maybe ffmpeg based is an option.
If not, for a commercial project I might license x264 commercially, if there is no way around that
I hope compose Multiplatform will provide something native in the future
a
Aren't libx264 and libx265 both encoders? FFmpeg (libavcodec) has its built-in decoders for h264 and hevc, so if you don't need encoding I believe you can just disable libx264 and libx265.
thank you color 1
m
JavaFX can do this, I think using native libs in some cases.
👍 1
So you could also embed a JavaFX view or something like that.
s
I hope someone builds an easy-to-use Apache 2/MIT/BSD library for that, so I don't need to figure out how to do that. 😅
MediaPlayer-KMP is unfortunately GPL
u
I really want to do a native implementation, under Linux it's very simple with gstreamer, under Windows as usual it's going to be a pain, but it'll be done. We just need someone to do it under Mac because I don't know.
s
My app is currently only available for Windows & macOS, with Windows (obviously) being the main audience
u
And linux ? 😰
s
Ashampoo sees no audience on Linux for their products 🤷‍♂️ But I of course include it in my side projects 😉
u
Phew, I'm reassured 😁
🙂 1
z
@אליהו הדס I've also been wanting to to a video player but using libmpv supporting all targets. I've got it working kinda but it's been.. difficult.. and im unsure how to display it in compose
u
@zt the easiest is to use gstreamer which is cross platform, I have already managed to make a functional desktop implementation, the problem is that it will add a hundred mb to the windows and mac application.
I will publish this soon
Otherwise for Windows, the best way would be to use https://github.com/mrfearless/MFPlayer-Library but as it is a fairly serious, unpleasant and probably hair-pulling job because it is Windows, I think I will leave that for my holidays in April.
https://github.com/kdroidFilter/Compose-Media-Player Check this, it's work on linux, I will try to implement the natives today for windows
🔥 1
😁
By the way, if someone wants to take care of the other platforms (Android, iOS, Wasm) during this time, that would be cool because I don't think I'll do it right away.
it works on windows, you just have to install gstreamer https://gstreamer.freedesktop.org/download/#windows , use MSVC 64-bit (VS 2019, Release CRT) 1.24.11 runtime installer install it on c, you need a complete installation, not typical otherwise indicate the path like this:
GStreamerInit.setGStreamerPathWindows("E:\\gstreamer\\1.0\\msvc_x86_64\\bin")
i imagine it works on mac
The main thing is that on Linux it is native 🤩
s
That's some really nice progress! 🙂 🎉
What are the benefits of GStreamer over ffmpeg? Just curious, I have no idea. 😅
And are there pre-built binaries for Windows as well that could be shipped in a commercial app? https://gstreamer.freedesktop.org/download/#windows looks like installers.
u
What are the benefits of GStreamer over ffmpeg?
FFMPEG is more suitable for file processing like conversions while Gstreamer is more suitable for file playback
💡 1
Gstreamer is under LGPL so a priori no problem
I'm trying to find a slightly simpler way than having the user install gstreamer 😅
👍 1
s
> Gstreamer is under LGPL so a priori no problem FFmpeg is too AFAIK. But if GStreamer has an easier to use API that's also a good reason. I was just curious, because I don't remember having heard of GStreamer before. 😅
Ah, I see https://github.com/gstreamer-java/gst1-java-core So they have first class Java support? ❤️
🚀 1
👍 1
u
Gstreamer is natively integrated into all Linux distributions I believe, and it seems to me that it is used by native video players like the one in Gnome.
🔥 1
Have you tried launching the project?
s
I checked it out right now and lowered the android SDK 😉
u
Under 21?
s
No, I meant AGP to 8.5.0 - I'm on an older IDEA 😄
🤣 1
I develop on macOS - do I need to install gstreamer using brew?
u
I have never used a mac in my life 😬
I guess you have to install it as described on the site
👍 1
s
You laugh... IDEA 2024.3.x has bad performance on Apple Silicon devices. Something is really off. 🤷‍♂️ Currently I'm skipping that version.
😬 1
u
Switch to Linux 😉
s
Yeah, must be installed using brew... the binary installers are not signed and not notarized. They won't install on a current Mac.
The project should ship the binaries and extract them... like skiko does.
u
Yes I will try to do that
if it doesn't work, set the gstreamer path with
GStreamerInit.setGStreamerPathMac()
Gstreamer is also available on android and ios, there is a way to make a real multiplatform player that works everywhere the same way
👍 1
But we will have to make the bindings for ios, and maybe android. I haven't checked how it works on android, it seems to use ndk
s
Yeah, I guess for a KMP app you could use the native video players and integrate them like everyone else does.
That's something people knowing how to do that can contribute
If not, I'll figure this out and send a PR by the time I add video support to my app
kodee happy 1
u
> That's something people knowing how to do that can contribute Yes, especially on iOS, I can do it on Android.
👍 1
s
The thing I've no clue about is how to add that media framework lib you mentioned via JNA to windows 😄
u
Ah I think you have to compile it in dynamic library, define predefined functions to use it and redirect the hwd window in compose. It's easy to say but to do, it's a big pain
s
The nice thing about the media framework is people can install codec packs on Windows and add support for all kinds of video files
u
The disadvantage is that we will not necessarily have the same result on all platforms.
The main advantage is that it would not add 100MB to the application.
s
Indeed. It's one dependency less and users can add more codecs on themselves. I think it's worth it.
u
I don't know if it's really worth it because it might make the code quite difficult to maintain.
This means that every time we want to add a feature, we will have to check if it is supported by the media foundation, or find alternatives each time.
For example gstreamer manages 2 pipelines, media foundation I don't know anything about it
s
What features would that be other than the ones (play, pause, etc.) are already implemented?
u
manage an audio and video stream separately for example
s
Ok, that would be advanced features for someone building a video tool or something like that. I guess most people are happy with playback. 😄
u
No just for a Youtube player 🙂
s
Ah, you mean selection of different language audio streams?
u
not necessarily but also, the youtube streams are divided into 2 streams, one audio and one video and the player synchronizes them
For example, this allows the audio to continue when you exit the application (if you have YouTube Premium) to only play the audio without using a lot of bandwidth.
Or as you said change the audio language but it's not very common
s
For me these use cases are not relevant. In Ashampoo Photo Organizer people just want to see their videos taken on a mobile phone - they have one audio and one video track.
👍 1
I figured out that you need to
brew install gstreamer-development
(not just gstreamer) to make it work on macOS. It works! 🙂 🚀
u
No, it works under Windows even without development mode, but you have to do a complete installation and not a typical one.
On Mac I don't really know
s
Yeah, mac needed the development things. I had something similar with vips-ffm lately, which needed libvips-dev to make it work.
u
But I'm glad it works. 🙂
s
I believe if you manage to make it work using GStreamer on desktop (mac & windows) without people needing to install Gstreamer (but you deliver it like skiko does) this alone is a huge achievement. You could start your library by that with full Kotlin Multiplatform on the roadmap. I see your library getting quite popular, because as we figured out there is yet no Compose Media library, so you still have the first mover advantage on your side 😄
👍 1
If that all works I'd still wish for an Windows media framework option/implementation (separate module?) to avoid growing the installation by 100 MB and having said "user can install their own codecs to make any video work" advantage.
u
well actually I found this, but I don't see the code https://github.com/Chaintech-Network/ComposeMultiplatformMediaPlayer
s
Yeah, I know of this. Ignore that. They are scammers if you ask me. They have a lot sample projects, but no actual library code. Won't use anything of that.
👍 1
u
If that all works I'd still wish for an Windows media framework option/implementation (separate module?) to avoid growing the installation by 100 MB and having said "user can install their own codecs to make any video work" advantage.
The technical challenge interests me above all, in addition to the 100mb less to download
👍 1
s
Yeah, I talked back to my CTO. He says one needs to pay attention using gstreamer, because it uses a lot of ffmpeg and it's likely some GPL code may slip into that by accident. He prefers using Windows Media just to be legally safe.
Personally I would prefer you using the https://github.com/mrfearless/MFPlayer-Library to have direct access to the media features with nothing in between.
Just for performance and less dependencies that can break. 😄
u
Yes, of course it's better in idea, it's just more work 🙂
👍 1
And when you do this kind of thing under Windows, you know when you start but not when you finish. 🤣
s
😄
u
Yeah, I talked back to my CTO. He says one needs to pay attention using gstreamer, because it uses a lot of ffmpeg and it's likely some GPL code may slip into that by accident. He prefers using Windows Media just to be legally safe.
Yes indeed you have to check the plugins https://gstreamer.freedesktop.org/documentation/plugin-development/appendix/licensing-advisory.html?gi-language=c
👍 1
s
ffmpeg states something similar.
u
and if the application does not contain gstreamer but downloads it from the site and installs it silently, we avoid any licensing problems, right?
I developed a library to install silently under windows
s
and if the application does not contain gstreamer but downloads it from the site and installs it silently, we avoid any licensing problems, right?
To my knowledge it doesn't work like that. You would need the user for consent - similar to what Audacity does with the contrib codecs.
u
yes of course you warn the user of the download and installation, but you do not display the gstreamer installer
s
Ah, ok. In that case the user may be prompted regarding consent from the system anyway - windows UAC
u
No, you don't have to install it as an administrator.
s
It's best to bundle a DLL with the JAR. Like skiko does.
u
yes it's better but it can cause licensing problems, I don't know which is GPL and which is not
s
For my app I use hydraulic conveyer - that does even extract the DLLs from JAR
yes it's better but it can cause licensing problems, I don't know which is GPL and which is not
If you deliver something with the installation you can make sure it's LGPL only. If you install something from an URL, the installer behind that URL may change
👍 1
That's another sample how to ship DLLs with the library itself. https://github.com/openpnp/opencv Skiko does it best, hassle-free https://github.com/JetBrains/skiko
u
yes I see that's what I thought, you just have to make one module per platform
👍 1
s
How nice of him 🙂💯
I love when maintainers deeply care about their libraries 👍
u
I was the one who asked him to generate dynamic libraries as well as headers, and he did it directly 🤩
s
I know, he wrote that in the issue #2 😄
u
Let everyone understand that this guy is probably a coding genius 🤩
s
Yeah, I will make sure I mention him and his lib separately in my hall of fame / photo organizers about section 😄
107 Views