Skip to main content

Movie decoder for Python based on MoviePy

This library allows you to decode and render movies in Python. It is based on the (rather excellent) MoviePy module created by Zulko, which offers a convenient Python interface to ffmpeg. This library should hence be able to decode any format that ffmpeg supports. If ffmpeg is not found to be installed, moviepy will download it for you on first use, which may take some time (keep an eye on that terminal/command prompt to see the download progress).

One will have to implement the actual rendering of each frame himself, but you can use the play.py module included in this repository as an example. The play.py shows how to play a video using OpenGL+pygame for the video rendering and pyaudio for audio playback (using pygame.mixer is also an option, but that doesn't work smoothly yet).

To see it run right away, you can invoke play.py with the following options:

usage: play.py [-h] [-d] [-f] [-l] [-s {pygame,pyaudio}] [-r RESOLUTION]
               mediafile

positional arguments:
  mediafile             the path to the media file to play

optional arguments:
  -h, --help            show this help message and exit
  -d, --debug           debugging mode: print lots of info
  -f, --fullscreen      show movie in fullscreen
  -l, --loop            loop the video
  -s {pygame,pyaudio}, --soundrenderer {pygame,pyaudio}
                        the backend that should render the sound (default:
                        pyaudio)
  -r RESOLUTION, --resolution RESOLUTION
                        The resolution of the video. Specify as
                        <width>x<height> (default: 1024x768)

This example player furthermore supports pausing playback (by pressing space), seeking 10s forward or backward (by pressing left or right arrow keys) and can be exited by pressing ESC or clicking the close button.

Dependencies

This module depends on the following other libraries.

That should be enough to get you started, if you plan to implement your own rendering functions for video and audio. If you also want to be able to view the example provided by play.py you further need

TODO's

This module is (and will probably always be) a 'work in progress'. For now

  • Implementing volume control functions.
  • Find a faster method than glTexSubImage2D to get the frame onto the texture to improve performance of the player (even though it works quite well now, it plays Big Buck Bunny at 1080p @60fps without too many dropped frames, but performance is still far behind to other players such as vlc).
  • Get pygame audiorenderer working with the current audioqueue implementation.
  • Let the decoder also work for audio-only streams/files.

are on my to-do list, but if you have more suggestions, feel free to open up an issue with a feature request.

API reference

Further documentation, including an API reference, can be found here.

License

Like moviepy, this module is licensed under the MIT license:

The MIT License (MIT) Copyright (c) 2016 Daniel Schreij

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for mediadecoder 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mediadecoder 0.2.3
File Size Uploaded
mediadecoder-0.2.3.tar.gz 15.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mediadecoder 0.2.3
File Interpreter ABI Platform
mediadecoder-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 34.7 kB

Release files / mediadecoder-0.2.3.tar.gz

Download URL mediadecoder-0.2.3.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5cded368d5a7f4bb1314fd5fcfb1e74e09f8e3fdbf6263c8d9fbd63758a8b41a
BLAKE2b-256 checksum
How to use checksums
3620f4b0bee0f116397b581c6d150108730e023e03b339bb91daa50c7a1d90d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / mediadecoder-0.2.3-py3-none-any.whl

Download URL mediadecoder-0.2.3-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08c99d9432301be80247df436d023a1c7042255f708cb3633361cc1211f260ef
BLAKE2b-256 checksum
How to use checksums
4c609f3c02208c086c6f9b950c2903962b0e0c74180b46134492c7daea87e5e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

3 release files

0.1.4

3 release files

0.1.3

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page