Pyglet can’t find codecs once it has been packaged by pyinstaller

I’m creating a simple media player. It will be used by non-coders, so I’d like for them to be able to launch it in an intuitive way, eg. by double clicking an .exe

The code I built works as desired in spyder. I managed to export it using pyinstaller, and when launched from powershell prompt in the correct environment, the executable works as expected (except for ghosting at the beginning, that I’m also working on.)

If I launch the executable from root, or by double clicking however, I get the following error:

Traceback (most recent call last):
  File "PygletCodec.py", line 7, in <module>
  File "pygletmedia__init__.py", line 142, in load
  File "pygletmedia__init__.py", line 132, in load
  File "pygletmediacodecswmf.py", line 880, in decode
  File "pygletmediacodecswmf.py", line 504, in __init__
  File "pygletmediacodecswmf.py", line 626, in _load_video
pyglet.media.exceptions.MediaDecodeException: [WinError -1072875852] Les données spécifiées pour le type de média ne sont pas valides, sont incohérentes ou ne sont pas prises en charge par cet objet
[13344] Failed to execute script 'blablabla' due to unhandled exception!

I’ve looked at the corresponding file on github, (Here) and the error is raised in the following lines:

        try:
            self._source_reader.SetCurrentMediaType(self._video_stream_index, None, uncompressed_mt)
        except OSError as err:  # Can't decode codec.
            raise DecodeException(err) from None

where the comment indicates that the codec can’t be used (and as whoever wrote it surely knows much better than I do, I’m inclined to agree).

The error can be reproduced by exporting the following minimal version of the code with pyinstaller (the command I used was simply “pyinstaller filename.py” as I hardcoded the full filepath for simplicity):

import pyglet

window = pyglet.window.Window(width = 1800, height= 1000)
player = pyglet.media.Player()
source = pyglet.media.load(r"full_filepath.mp4")

player.queue(source)
player.play()

@window.event
def on_draw():
    window.clear()
    if player.source and player.source.video_format:
        player.get_texture().blit(0, 0)

pyglet.app.run()

I’m from a more scientific use background, so don’t know much about codecs or media playback, though I’ve been trying to learn. Thank you for any help.

I thought that codecs were available system wide, so I don’t understand why they can’t be found. Pyglet seems to have been imported without problem, and I can’t see a secondary import that’s failing, so I don’t understand what one environment has access to that the other doesn’t.

I’ve tried building and playing the executable on two windows computers that I have available to me, with the same results. I’ve tried changing the codec used to build the video. I’ve asked chatgpt which says that the problem is pyglet can’t access windows media framework, but I hon’t know how to import this manually.

New contributor

THFermat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật