macOS : How deploy vlc3 to avoid libvlc_new crash at runtime

This forum is about all development around libVLC.
amn
New Cone
New Cone
Posts: 6
Joined: 13 Oct 2020 16:23

macOS : How deploy vlc3 to avoid libvlc_new crash at runtime

Postby amn » 22 Oct 2020 09:46

Hi everybody,
I'm trying to use vlc3 (libvlc) with Qt(5.14) clang under MacOsx(10.15)
So I'm using vlc/doc/libvlc/QtPlayer
but at runtime I always have the message : Could not init libVLC
It's because libvlc_new(0,NULL) return nil !!

Trying change args to init vlc

Code: Select all

const char * const vlc_args[] = {"--verbose=2","--vout=macosx"}; vlcInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
still return nil

pro file links libraries with :

Code: Select all

INCLUDEPATH += /Applications/VLC.app/Contents/MacOS/include LIBS += -L/Applications/VLC.app/Contents/MacOS/lib
then I try with LIBS += -L/opt/X11/lib -lX11 and without.
To be sure there is no @rpath problems in vlc libraries, I keep the tree structure of VLC.app by copying directly in build/qtvlc.app/Contents/MacOS/ :
VLC.app/Contents/Frameworks/
VLC.app/Contents/MacOS/lib/
VLC.app/Contents/MacOS/plugins/

I add @rpath to MacOS/qtvlc executable :

Code: Select all

sudo install_name_tool -delete_rpath /Users/amn/Qt/5.15.0/clang_64/lib /Users/amn/test-vlc/vlc-3.0/doc/libvlc/build/qtvlc.app/Contents/MacOS/qtvlc sudo install_name_tool -add_rpath @executable_path/lib/ /Users/amn/test-vlc/vlc-3.0/doc/libvlc/build/qtvlc.app/Contents/MacOS/qtvlc sudo install_name_tool -add_rpath @executable_path/plugins/ /Users/amn/test-vlc/vlc-3.0/doc/libvlc/build/qtvlc.app/Contents/MacOS/qtvlc
but libvlc_new(0,NULL) still return nil.

---
Then If I'm trying to use libvlc (libvlcpp/vlcpp/*) in my own project, with the same deployment process, at runtime, libvlc instanciation crashes.

Code: Select all

const char * const vlc_args[] = {"--verbose=2","--vout=macosx"}; new VLC::Instance(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
crash with the message :
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Wrapping a NULL instance

I don't have this problem with vlc4 (no crash at runtime), but I can't see the video output with vlc4 even if the video is played (I hear the sound)
So, I'm trying with vlc3, but it crashes.

---
If somebody can explain how deploy vlc3 in vlc/doc/libvlc/QtPlayer,
according to avoid libvlc_new(0,NULL) return nil,
it would be really appreciated.
Thanks a lot in advance.

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: macOS : How deploy vlc3 to avoid libvlc_new crash at runtime

Postby mfkl » 26 Oct 2020 08:49

Can you share the setup of your directory tree (libvlc, libvlccore, plugins folder) please?

Have you tried to set the VLC_PLUGIN_PATH environment variable?
https://mfkl.github.io

amn
New Cone
New Cone
Posts: 6
Joined: 13 Oct 2020 16:23

Re: macOS : How deploy vlc3 to avoid libvlc_new crash at runtime

Postby amn » 02 Nov 2020 18:03

Thanks for this advice, I'm setting VLC_PLUGIN_PATH by :

Code: Select all

QByteArray ba=QString("/Applications/VLC.app/Contents/MacOS/plugins").toUtf8(); qputenv("VLC_PLUGIN_PATH",ba);
and QtPlayer works fine ! Thanks a lot!
I don't see the video in my own project, which use libvlcpp (QtPlayer don't), but it concern a new post if necessary,
the runtime crash has disappeared.
Thanks again.

Timothy Grove
Blank Cone
Blank Cone
Posts: 33
Joined: 07 Sep 2011 13:17

Re: macOS : How deploy vlc3 to avoid libvlc_new crash at runtime

Postby Timothy Grove » 18 Nov 2020 19:31

Curious, where did you place the code to set VLC_PLUGIN_PATH? In player.cpp:Mwindow? Having similar problem with QtPlayer.

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: macOS : How deploy vlc3 to avoid libvlc_new crash at runtime

Postby mfkl » 19 Nov 2020 05:10

Curious, where did you place the code to set VLC_PLUGIN_PATH? In player.cpp:Mwindow? Having similar problem with QtPlayer.
anytime before the first libvlc call.
https://mfkl.github.io


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 14 guests