Skip to main content

Media-decoding library based on MoviePy

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mediadecoder-0.2.3.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mediadecoder-0.2.3-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file mediadecoder-0.2.3.tar.gz.

File metadata

  • Download URL: mediadecoder-0.2.3.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for mediadecoder-0.2.3.tar.gz
Algorithm Hash digest
SHA256 5cded368d5a7f4bb1314fd5fcfb1e74e09f8e3fdbf6263c8d9fbd63758a8b41a
MD5 032a826a10122b456cf594f86edf1259
BLAKE2b-256 3620f4b0bee0f116397b581c6d150108730e023e03b339bb91daa50c7a1d90d4

See more details on using hashes here.

File details

Details for the file mediadecoder-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: mediadecoder-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for mediadecoder-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 08c99d9432301be80247df436d023a1c7042255f708cb3633361cc1211f260ef
MD5 06d603cb9c830ca9280aec8838a41fe9
BLAKE2b-256 4c609f3c02208c086c6f9b950c2903962b0e0c74180b46134492c7daea87e5e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page