2016-06-12 79 views
2

我目前正在使用RPi 3B(最新的Raspbian Jessie)在一個小項目上工作,該項目涉及播放一個簡短的.mp4文件。由於Pygame似乎支持播放.mpg文件,所以我將視頻轉換爲該格式。Pygame.movi​​e missing

當我試圖但是進口電影模塊,我得到了普遍的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是最新的。

+1

您好,歡迎光臨[計算器](http://stackoverflow.com), 的政策是讓每個「page'.You只有一個問題可能會喜歡閱讀[this](http://stackoverflow.com/help/how-to-ask)。 –

回答

2

movie不是pygame

子包使用方法如下:

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

不過請注意:

電影API已被棄用,你的pygame的將最有可能不包含任何代碼爲此api。

該代碼只會引發NotImplementedError異常。

不幸的是你不能使用pygame來播放這樣的電影。

Here萊納德林川解釋這一點:

"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."

+0

現在很簡單!然而,我現在正在收到「NotImplementedError」 - - – xXliolauXx