caprica / vlcj

Java framework for the vlc media player
http://www.capricasoftware.co.uk/projects/vlcj
1.13k stars 259 forks source link

Embed necessary lib with app, so that VLC installation isn't required? #1149

Closed ScottPierce closed 2 years ago

ScottPierce commented 2 years ago

Is it possible to embed the necessary library / app so that VLC installation isn't required? Many people who have tried this library with compose have found that it won't function unless VLC is installed. I tried looking through the documentation and I didn't see anything that clearly explained this.

caprica commented 2 years ago

It generally isn't possible.

It might work on Windows, but you would have to include the dlls in some installation file, or your jar file, and then you have to write something to unpack those dlls to a temporary folder or something.

On Linux and macOS as far as my understanding goes the shared objects are generally not relocatable, so it won't work.

Whenever this comes up, I really don't comprehend why developers won't just use the standard OS installation methods to install those dependencies.

ScottPierce commented 2 years ago

What files does vlcj use? It's not possible to just download those at runtime, or package them with the installed application?

Whenever this comes up, I really don't comprehend why developers won't just use the standard OS installation methods to install those dependencies.

Primarily because it's a very ugly solution. Asking the user to do something else in addition to what they've done. What happens if they uninstall VLC, or have the wrong version installed, etc. It's something that becomes difficult to control, and it's a bad user experience.

caprica commented 2 years ago

I don't agree that it's ugly or bad UX to use a standard OS installation package solution.

In any case, the files vlcj uses are the shared libraries (.dll, .so, *.dylib) installed by VLC, starting with e.g. libvlc.dll and libvlccore.dll, and then all the files in the VLC plugins directory.

If you want to include them all in your own Java app, go for it. Be prepared to write code to unpack those shared objects from your jar file at run-time. And be prepared for it probably only working on Windows.

mahozad commented 1 year ago

@caprica

I'm creating a Desktop app with ability to play video (with Compose Multiplatform).

Unfortunately, we cannot simply assume that VLC has been installed on users systems. Instructing users to install VLC is a little hard too. Also, embedding the VLC setup file in our installer (if that's possible) makes its size bigger.

I found this library called JavaCV. It uses JNI to interface with FFmpeg and more. The author seems to publish library artifacts for all platforms. For example, for FFmpeg: https://repo1.maven.org/maven2/org/bytedeco/ffmpeg/5.1.2-1.5.8/

So, to call FFmpeg libraries or even run its executable binary we can include this two dependencies and we are good to go:

implementation("org.bytedeco:javacv:1.5.8")
runtimeOnly("org.bytedeco:ffmpeg:5.1.2-1.5.8:windows-x86_64") // Platform-specific artifact

Is there any chance you could embed the required VLC dll or so files in the published artifact like what that library does?

I think the issue https://github.com/caprica/vlcj/issues/1041 is related.

caprica commented 1 year ago

Is there any chance you could embed the required VLC dll or so files in the published artifact like what that library does?

No.

However, nothing prevents you from doing that.

I don't buy the argument about installer size - the installer size is bigger, so what?

caprica commented 1 year ago

Indeed, nothing prevents you from including the DLLs directly in your own application, as long as you extract them at run-time.

mahozad commented 1 year ago

Is it at least possible for you to specify exactly which DLLs should be included for Windows x64?

Just to: play/pause the video/audio increase/decrease playback speed seek get progress set audio volume

caprica commented 1 year ago

Unfortunately no.

There is no VLC documentation that says which plugins are needed for which functionality.

But the plugins are much more than the basic high-level items you list - it depends what input sources you want to support, what video codecs you need, and so on.

That's for you to work out for yourself based on your own project's requirements.