Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg does not work/load #1069

Open
pivtom opened this issue Mar 12, 2024 · 3 comments
Open

ffmpeg does not work/load #1069

pivtom opened this issue Mar 12, 2024 · 3 comments

Comments

@pivtom
Copy link

pivtom commented Mar 12, 2024

Hi, trying to run my script that uses pyglet to play a video, and am getting errors about the avutil library.

Am on M1 Mac,
Python 3.11.6
pyglet==2.0.14
ffmpeg==1.4
ffmpeg-python==0.2.0
python-ffmpeg==2.0.10

pyglet.media.have_ffmpeg() says False although latest ffmpeg installed and in path

And when trying to do this import, it gives the error below.
Thanks for any help in advance!
TP

from pyglet.media.codecs.ffmpeg import FFmpegDecoder

ImportError Traceback (most recent call last)
Cell In[3], line 1
----> 1 from pyglet.media.codecs.ffmpeg import FFmpegDecoder

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyglet/media/codecs/ffmpeg.py:15
13 from .base import AudioData, SourceInfo, StaticSource
14 from .base import StreamingSource, VideoFormat, AudioFormat
---> 15 from .ffmpeg_lib import *
16 from ..exceptions import MediaFormatException
19 class FileInfo:

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyglet/media/codecs/ffmpeg_lib/init.py:2
1 """FFmpeg wrapping"""
----> 2 from .libavcodec import *
3 from .libavutil import *
4 from .libavformat import *

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyglet/media/codecs/ffmpeg_lib/libavcodec.py:11
9 from pyglet.util import debug_print
10 from . import compat
---> 11 from . import libavutil
13 _debug = debug_print('debug_media')
15 avcodec = pyglet.lib.load_library(
16 'avcodec',
17 win32=('avcodec-60', 'avcodec-59', 'avcodec-58'),
18 darwin=('avcodec.60', 'avcodec.59', 'avcodec.58')
19 )

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyglet/media/codecs/ffmpeg_lib/libavutil.py:13
9 from . import compat
11 _debug = debug_print('debug_media')
---> 13 avutil = pyglet.lib.load_library(
14 'avutil',
15 win32=('avutil-58', 'avutil-57', 'avutil-56'),
16 darwin=('avutil.58', 'avutil.57', 'avutil.56')
17 )
19 avutil.avutil_version.restype = c_int
20 compat.set_version('avutil', avutil.avutil_version() >> 16)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyglet/lib.py:135, in LibraryLoader.load_library(self, *names, **kwargs)
132 if _debug_lib:
133 print(f"Unexpected error loading library {name}: {str(o)}")
--> 135 raise ImportError(f'Library "{names[0]}" not found.')

ImportError: Library "avutil" not found.

@Square789
Copy link
Contributor

You might have followed https://ffmpeg.org//download.html to the unofficial mac builds, it's possible you installed a prerelease version (pseudo-7.x.x) whose set of libraries are too recent.
Try installing ffmpeg 6.1.1, which should be the latest available ffmpeg release right now. That one includes avutil/avcodec etc. at versions supported by pyglet.
And fwiw the python packages are all bindings that do not contain the ffmpeg libraries, so you may want to uninstall those again.

@pivtom
Copy link
Author

pivtom commented Mar 14, 2024

Hi, thanks. No, I actually have ffmpeg 6.1.1. installed. I tried to install pyglet-1.5.28, there the problem with avutil does not occur. But when I reinstall the current version, either with pip3 or if I compile it, there is still the same issue.

when I want to do this:

from pyglet.media.codecs.ffmpeg import FFmpegDecoder

I get this:

File ~/Library/Python/3.11/lib/python/site-packages/pyglet-2.0.14-py3.11.egg/pyglet/media/codecs/ffmpeg.py:15
     13 from .base import AudioData, SourceInfo, StaticSource
     14 from .base import StreamingSource, VideoFormat, AudioFormat
---> 15 from .ffmpeg_lib import *
     16 from ..exceptions import MediaFormatException
     19 class FileInfo:

File ~/Library/Python/3.11/lib/python/site-packages/pyglet-2.0.14-py3.11.egg/pyglet/media/codecs/ffmpeg_lib/__init__.py:2
      1 """FFmpeg wrapping"""
----> 2 from .libavcodec import *
      3 from .libavutil import *
      4 from .libavformat import *

File ~/Library/Python/3.11/lib/python/site-packages/pyglet-2.0.14-py3.11.egg/pyglet/media/codecs/ffmpeg_lib/libavcodec.py:11
      9 from pyglet.util import debug_print
     10 from . import compat
---> 11 from . import libavutil
     13 _debug = debug_print('debug_media')
     15 avcodec = pyglet.lib.load_library(
     16     'avcodec',
     17     win32=('avcodec-60', 'avcodec-59', 'avcodec-58'),
     18     darwin=('avcodec.60', 'avcodec.59', 'avcodec.58')
     19 )

File ~/Library/Python/3.11/lib/python/site-packages/pyglet-2.0.14-py3.11.egg/pyglet/media/codecs/ffmpeg_lib/libavutil.py:13
      9 from . import compat
     11 _debug = debug_print('debug_media')
---> 13 avutil = pyglet.lib.load_library(
     14     'avutil',
     15     win32=('avutil-58', 'avutil-57', 'avutil-56'),
     16     darwin=('avutil.58', 'avutil.57', 'avutil.56')
     17 )
     19 avutil.avutil_version.restype = c_int
     20 compat.set_version('avutil', avutil.avutil_version() >> 16)

File ~/Library/Python/3.11/lib/python/site-packages/pyglet-2.0.14-py3.11.egg/pyglet/lib.py:135, in LibraryLoader.load_library(self, *names, **kwargs)
    132             if _debug_lib:
    133                 print(f"Unexpected error loading library {name}: {str(o)}")
--> 135 raise ImportError(f'Library "{names[0]}" not found.')

ImportError: Library "avutil" not found.

@caffeinepills
Copy link
Collaborator

caffeinepills commented Mar 14, 2024

ImportError is just an error saying it can't find your ffmpeg files. You should only be trying to import the decoder manually if pyglet.media.have_ffmpeg() is True. You need to ensure your ffmpegs dylib files are in the correct path and being found. If you still can't get it found by your system, you may have to specify the path. See more information here: https://pyglet.readthedocs.io/en/latest/programming_guide/media.html#ffmpeg-installation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants