Coder Social home page Coder Social logo

Comments (27)

mrJean1 avatar mrJean1 commented on September 2, 2024 1

None for vlc.Instance is the direct result from LibVLC function libvlc_new and not a Python or python_vlc issue.

Google for "libvlc_new returns null" and see whether any of those issue apply to your particular case.

Also, check the forum at VideoLAN.org, one entry there mentions that libvlc_new may return NULL if a plugin can't be found. The plugins folder exists but may not be populated properly?

For example, there may be plugins in that folder /Applications/VLC.app/Contents/MacOS/plugin from an older version of VLC or for the Intel processor. Delete everything in the folder, see if that helps. Then, reinstall the M version of VLC.

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

It looks like Python is built for Apple Si, native. Is VLC App app or is that an Intel build? Double check that both are built for the same target.

For example, Python 3.10.8 and VLC 3.0.18 both for Apple Si work fine (with some messages) using the examples tkvlc.py.

% python3.10 vlc.py -v
vlc.py: 3.0.16120 (Mon Feb 28 20:29:27 2022 3.0.16)
LibVLC version: 3.0.18 Vetinari (0x3001200)
LibVLC compiler: clang: warning: argument unused during compilation: '-mmacosx-version-min=10.7' [-Wunused-command-line-argument]
Plugin path: /Applications/VLC.app/Contents/MacOS/plugins
Python: 3.10.8 (64bit) macOS 14.4.1

[% python3.10 tkvlc.py 
2024-05-12 10:14:36.820 Python[39798:3441818] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
[0000000121f08fc0] videotoolbox decoder: Using Video Toolbox to decode 'h264'
[0000000121f08fc0] videotoolbox decoder: vt cvpx chroma: 420v

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

It looks like Python is built for Apple Si, native. Is VLC App app or is that an Intel build? Double check that both are built for the same target.

For example, Python 3.10.8 and VLC 3.0.18 both for Apple Si work fine (with some messages) using the examples tkvlc.py.

% python3.10 vlc.py -v
vlc.py: 3.0.16120 (Mon Feb 28 20:29:27 2022 3.0.16)
LibVLC version: 3.0.18 Vetinari (0x3001200)
LibVLC compiler: clang: warning: argument unused during compilation: '-mmacosx-version-min=10.7' [-Wunused-command-line-argument]
Plugin path: /Applications/VLC.app/Contents/MacOS/plugins
Python: 3.10.8 (64bit) macOS 14.4.1

[% python3.10 tkvlc.py 
2024-05-12 10:14:36.820 Python[39798:3441818] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
[0000000121f08fc0] videotoolbox decoder: Using Video Toolbox to decode 'h264'
[0000000121f08fc0] videotoolbox decoder: vt cvpx chroma: 420v

I have installed VLC Version 3.0.16 Vetinari (Apple Silicon) that's downloaded from official website.

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

What does the command line show now ...

python3.10  vlc.py  -v

The instance should not be None.

% python3.10
Python 3.10.8 ... on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import vlc
>>> i = vlc.Instance()
>>> i
<vlc.Instance object at 0x101170250>
>>> 

Also, get the tkvlc.py example and try ...

python3.10  tkvlc.py  -v

Example ...

% python3.10 tkvlc.py -v
2024-05-12 14:42:13.337 Python[65746:3646528] WARNING: ... returning YES.
tkvlc.py: 22.12.28
tkinter: 8.6
libTk: /Library/Frameworks/Python.framework/Versions/3.10/lib/libtk8.6.dylib
is_Tk: aqua
vlc.py: 3.0.16120 (Mon Feb 28 20:29:27 2022 3.0.16)
LibVLC version: 3.0.18 Vetinari (0x3001200)
LibVLC compiler: clang: warning: ... [-Wunused-command-line-argument]
Plugin path: /Applications/VLC.app/Contents/MacOS/plugins
Python: 3.10.8 (64bit) macOS 14.4.1

Lastly, play a video ...

python3.10  tkvlc.py  <video_file_name>

Keep in mind, running ...

python3.10  vlc.py  <video_file_name>

will not play the video on macOS, only the sound. For more details, see the examples.

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

What does the command line show now ...

python3.10  vlc.py  -v

The instance should not be None.

% python3.10
Python 3.10.8 ... on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import vlc
>>> i = vlc.Instance()
>>> i
<vlc.Instance object at 0x101170250>
>>> 

Also, get the tkvlc.py example and try ...

python3.10  tkvlc.py  -v

Example ...

% python3.10 tkvlc.py -v
2024-05-12 14:42:13.337 Python[65746:3646528] WARNING: ... returning YES.
tkvlc.py: 22.12.28
tkinter: 8.6
libTk: /Library/Frameworks/Python.framework/Versions/3.10/lib/libtk8.6.dylib
is_Tk: aqua
vlc.py: 3.0.16120 (Mon Feb 28 20:29:27 2022 3.0.16)
LibVLC version: 3.0.18 Vetinari (0x3001200)
LibVLC compiler: clang: warning: ... [-Wunused-command-line-argument]
Plugin path: /Applications/VLC.app/Contents/MacOS/plugins
Python: 3.10.8 (64bit) macOS 14.4.1

Lastly, play a video ...

python3.10  tkvlc.py  <video_file_name>

Keep in mind, running ...

python3.10  vlc.py  <video_file_name>

will not play the video on macOS, only the sound. For more details, see the examples.

python3.10 vlc.py -v shows exactly the same I texted in my first comment:

vlc.py: 3.0.20123 (Sat Nov  4 17:10:43 2023 3.0.20)
libVLC: 3.0.16 Vetinari (0x3001000)
plugins: /Applications/VLC.app/Contents/MacOS/plugins
Python: 3.10.14 (64bit) macOS 14.4.1 arm64

python3.10 tkvlc.py -v shows:

tkvlc.py: 22.12.28
tkinter: 8.6
libTk: /opt/homebrew/lib/libtk8.6.dylib
is_Tk: aqua, isAquaTk, isCocoaTk
vlc.py: 3.0.20123 (Sat Nov  4 17:10:43 2023 3.0.20)
libVLC: 3.0.16 Vetinari (0x3001000)
plugins: /Applications/VLC.app/Contents/MacOS/plugins
Python: 3.10.14 (64bit) macOS 14.4.1 arm64

and vlc.Instance() still returns None:

Python 3.10.14 (main, Mar 19 2024, 21:46:16) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import vlc
>>> i = vlc.Instance()
>>> print(i)
None
>>> 

As expected, python3.10 tkvlc.py <video_file_name> rises an error:

Traceback (most recent call last):
  File "/python-vlc/examples/tkvlc.py", line 1307, in <module>
    player = Player(root, video=_video, debug=_debug)
  File "/python-vlc/examples/tkvlc.py", line 601, in __init__
    self.player = self.Instance.media_player_new()
AttributeError: 'NoneType' object has no attribute 'media_player_new'

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

There may be more confusion. Since the tklib is the Homebrew one, the Python build should be Homebrew, but may not be. Type …

% python3.10
>>> import sys
>>> print(sys.executable)

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

There may be more confusion. Since the tklib is the Homebrew one, the Python build should be Homebrew, but may not be. Type …

% python3.10
>>> import sys
>>> print(sys.executable)

It doesn't look that tklib can be a reason of this problem, because I create an instance of vlc.Instance separately of any frameworks.

Anyway, output of sys.executable:

>>> import sys
>>> print(sys.executable)
/opt/homebrew/opt/[email protected]/bin/python3.10

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

Well, tklib may not be the issue, but Homebrew on Apple Si may. Both tkvlc.py and vlc.py haven been tested with Homebrew builds of Python and Tk/Tcl on Intel macOS using VLC for Intel. Especially example tkvlc.py was updated recently to handle the Homebrew specifics, see the tkvlc.py source.

Don't know about Homebrew builds for Apple Si. It could be a ctypes issue or something else, unrelated to Python, VLC and vlc.py (and Tk/Tcl and tkvlc.py). Standard Python works just fine with vlc.py and examples.

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

I did where python3.10 and found out that there's three python 3.10 on my machine:

/opt/homebrew/bin/python3.10
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
/usr/local/bin/python3.10

I tried to execute vlc.py by each one but no one interpreter works with vlc.Instance.

It's hard to believe that there's nobody who has the same problem, definitely I do something wrong :(

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

FWIW, I just installed Python 3.12 from Homebrew, imported vlc.py and the vlc.Instance is fine, at least not None.

% /opt/local/bin/python3 
Python 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import vlc
>>> i = vlc.Instance()
>>> i
<vlc.Instance object at 0x102d4ca70>

PS) The are quite a number SyntaxWarning: invalid escape sequence ... in vlc.py, but those have no effect.

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

FWIW, I just installed Python 3.12 from Homebrew, imported vlc.py and the vlc.Instance is fine, at least not None.

% /opt/local/bin/python3 
Python 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import vlc
>>> i = vlc.Instance()
>>> i
<vlc.Instance object at 0x102d4ca70>

PS) The are quite a number SyntaxWarning: invalid escape sequence ... in vlc.py, but those have no effect.

This is under intel chip or apple?

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

macOS Sonoma 14.4.1 Apple M1 macBook Air

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

macOS Sonoma 14.4.1 Apple M1 macBook Air

My mac is the same.
If I understood correctly you built your own VLC from source, right?

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

Also, tkvlc.py does not work since python 3.12.3 in Homebrew doesn't have the tkinter module even though tcl-tk 8.6.14 is installed in Homebrew. Correction: tkvlc.py works fine after brew install python-tk.

Finally, example cocoavlc.py does play a video but that is all. Other windows, dialogs, etc do not work on 'Homebrew'. Perhaps there is a ctypes issue, cocoavlc.py depends on PyCocoa which depends heavily on ctypes to get to a handful of macOS libraries.

With any standard Python build for Apple Si, cocoavlc.py works fine with the latest PyCocoa and VLC 3.0.18 or earlier.

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

No. All VLC and Python are pre-built releases from their respective web-sites.

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

No. All VLC and Python are pre-built releases from their respective web-sites.

Then it's really weird. I use the same Python and VLC builds on the same machine, but the behavior is different.

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

VLC is the VLC app and Python is a std build? Not Homebrew?

In any case, get Python 3.11 or 3.12 from Python.org. Those install next to 3.10 and will not override the latter. Then, check the vlc.Instance, it shouldn’t be None.

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

VLC is the VLC app and Python is a std build? Not Homebrew?

Yes, VLC for MacOs from here and Python from here

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

VLC is the VLC app and Python is a std build? Not Homebrew?

In any case, get Python 3.11 or 3.12 from Python.org. Those install next to 3.10 and will not override the latter. Then, check the vlc.Instance, it shouldn’t be None.

I installed Python 3.11 from python.org and it didn't help.

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

What is the output of …

python3.11  vlc.py  -v

python3.11  tkvlc.py  -v

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

What is the output of …

python3.11  vlc.py  -v

python3.11  tkvlc.py  -v
% /Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11 vlc.py -v

vlc.py: 3.0.20123 (Sat Nov  4 17:10:43 2023 3.0.20)
libVLC: 3.0.16 Vetinari (0x3001000)
plugins: /Applications/VLC.app/Contents/MacOS/plugins
Python: 3.11.9 (64bit) macOS 14.4.1 arm64
% /Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11 tkvlc.py -v

tkvlc.py: 22.12.28
tkinter: 8.6
libTk: /Library/Frameworks/Python.framework/Versions/3.11/lib/libtk8.6.dylib
is_Tk: aqua, isAquaTk, isCocoaTk
vlc.py: 3.0.20123 (Sat Nov  4 17:10:43 2023 3.0.20)
libVLC: 3.0.16 Vetinari (0x3001000)
plugins: /Applications/VLC.app/Contents/MacOS/plugins
Python: 3.11.9 (64bit) macOS 14.4.1 arm64

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

This looks normal, correct. It is not possible to diagnose the issue further … remotely, sorry.

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

This looks normal, correct. It is not possible to diagnose the issue further … remotely, sorry.

Yeah, I see. Thanks a lot for helping me!

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

libvlc_new returns null

Oh, man, it turned out to be so easy. Just setting the environment variable:

VLC_PLUGIN_PATH=/Applications/VLC.app/Contents/MacOS/plugins

solved my problem. It's literally the first link in Google results.

Thank you so much again!

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

That’s strange because … that is the exact same plugins paths vlc.py found and showed when run with the -v command line option.

from python-vlc.

kravlad avatar kravlad commented on September 2, 2024

vlc.py doesn't look at environment variables, the path is hardcoded:

elif sys.platform.startswith('darwin'):
    # FIXME: should find a means to configure path
    d = '/Applications/VLC.app/Contents/MacOS/'
    c = d + 'lib/libvlccore.dylib'
    p = d + 'lib/libvlc.dylib'
    if os.path.exists(p) and os.path.exists(c):
        # pre-load libvlccore VLC 2.2.8+
        ctypes.CDLL(c)
        dll = ctypes.CDLL(p)
        for p in ('modules', 'plugins'):
            p = d + p
            if os.path.isdir(p):
                plugin_path = p
                break

from python-vlc.

mrJean1 avatar mrJean1 commented on September 2, 2024

True. And it is the same path (before /plugins).

Something else must be wrong or off, because earlier, vlc.py found the same /Applications/VLC.app/Contents/MacOS/plugins folder on its own, without setting env var VLC_PLUGIN_PATH.

Maybe, file /Applications/VLC.app/Contents/MacOS/lib/libvlccore.dylib does not exist on your machine (but file /Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib does).

Btw, which flavor of vlc.py is this, generated/3.0/vlc.py or generated/2.2/vlc.py?

from python-vlc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.