python - Pygame.movi​​e 丢失

标签 python raspberry-pi pygame raspbian movie

<分区>

我目前正在使用 RPi 3B(最新的 Raspbian Jessie)进行一个涉及播放短 .mp4 文件的小项目。由于 Pygame 似乎支持播放 .mpg 文件,因此我将我的视频转换为该格式。

然而,当我尝试导入电影模块时,出现了常见的 python 导入错误:

Traceback (most recent call last):
    File "film_app.py", line 3, in <module>
       import pygame.movie
ImportError: No module named movie

经过一些研究,我认为其他人也遇到了与所述相同的问题 here .我真的不明白是否有解决方案,或者我在 RPi 上有什么替代方案。

Pygame、python 和 Raspbian 是最新的。

最佳答案

movie 不是 pygame

的子包

像这样使用它:

movie = pygame.movie.Movie("file.mpg")

但是请注意:

电影 api 已弃用,您的 pygame 很可能不包含此 api 的任何代码。

代码只会抛出 NotImplementedError 异常。

遗憾的是,您不能再将 pygame 用于此类电影。

Here Lenard Lindstrom 解释说:

"Though not properly documented, the pygame.movie module has been deprecated for some time, and was no longer built by default. The documented instructions for converting video files to MPEG1 using ffmpeg are outdated. I built the movie module was built and tested on 32-bit Linux Mint 17.1 (Ubuntu 14.04.2 LTS, Trusty Tahr) and tested it on a movie converted from MPEG4 using avconv (a fork of ffmpeg); pygame segfaulted. Also note that pygame.movie was problematic under Windows.

The newer, experimental pygame._movie module, based on ffmpeg, never worked for me on Linux; it would lock up. Also, libav is now preferred over ffmpeg on Linux. Furthermore, it relies on SDL overlays, which disappear in SDL2.

As a side note, pygame.examples.movieplayer was re-purposed to use pygame._movie instead of pygame.movie. This change was undocumented.

I like the idea of movie support in Pygame. But pygame.movie uses the outdated smpeg library, and pygame._movie never quite worked right. Maybe another movie module can be written based on an existing command line movie player program."

关于python - Pygame.movi​​e 丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37775635/

相关文章:

python - Pandas 连续移除异常值

linux - 在 Raspberry PI 中,如何实现对 SD 卡的最小写入周期并随时拔下 RPI?

c# - 在 C# 应用程序中播放 Raspberry Pi h264 流

python - Pygame (python) 中翻转图像的问题

python - 我无法制作 1x1 矩形

python - pygame.transform.rotate 不工作

python - 在 Python 3 中生成具有随机长度的类似随机的唯一字符串的最快方法

python - 给定输入日期作为字符串查找年龄(以天为单位)

python - 在 pip.py 中设置代理

python - 如何在 Python 中使用 BLE 通知