Pygame.movie missing

I am currently working with a RPi 3B (latest Raspbian Jessie) on a little project which involves playing a short .mp4 file. As Pygame seemed to support playing .mpg files, so I converted my video into that format.

When I tried to import the movie module however, I get the common python import error:

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

After some research, I figured others had the same issue as described here. I did not really understand if there is a solution to it, or what alternatives I have on a RPi.

Pygame, python and Raspbian are up to date.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

movie is not a sub package of pygame

Use it like this:

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

Note however:

The movie api is deprecated and your pygame will most likely not contain any code for this api.

The code will just throw a NotImplementedError exception.

Sadly you cant use pygame for movies like this anymore.

Here Lenard Lindstrom explains this:

“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.”

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply