Skip to content

Commit 4eb543f

Browse files
committed
Put media decoder part in separate library
0 parents  commit 4eb543f

File tree

13 files changed

+1356
-0
lines changed

13 files changed

+1356
-0
lines changed

.gitignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
47+
# Translations
48+
*.mo
49+
*.pot
50+
51+
# Django stuff:
52+
*.log
53+
54+
# Sphinx documentation
55+
docs/_build/
56+
57+
# PyBuilder
58+
target/
59+
60+
build_all

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#Movie decoder for Python based on MoviePy
2+
3+
This library allows you to play and render movies in Python. It is based on the
4+
(rather excellent) [MoviePy](http://zulko.github.io/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 usage, which may take some time (keep an eye on that terminal/command prompt to see the download progress).
5+
6+
The actual rendering of each frame one will have to implement himself, but you can use the play.py module included in this repository as an example. The `play.py` file contains an example of 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).
7+
8+
To see it run right away, you can invoke play.py with the following options:
9+
10+
~~~
11+
usage: play.py [-h] [-d] [-f] [-l] [-s {pygame,pyaudio}] [-r RESOLUTION]
12+
mediafile
13+
14+
positional arguments:
15+
mediafile the path to the media file to play
16+
17+
optional arguments:
18+
-h, --help show this help message and exit
19+
-d, --debug debugging mode: print lots of info
20+
-f, --fullscreen show movie in fullscreen
21+
-l, --loop loop the video
22+
-s {pygame,pyaudio}, --soundrenderer {pygame,pyaudio}
23+
the backend that should render the sound (default:
24+
pyaudio)
25+
-r RESOLUTION, --resolution RESOLUTION
26+
The resolution of the video. Specify as
27+
<width>x<height> (default: 1024x768)
28+
~~~
29+
30+
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.
31+
32+
## Dependencies
33+
34+
This module depends on the following other libraries.
35+
36+
- MoviePy (http://zulko.github.io/moviepy/)
37+
- pyAudio (https://people.csail.mit.edu/hubert/pyaudio/)
38+
39+
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
40+
41+
- pygame (http://www.pygame.org/)
42+
- pyOpenGL (http://pyopengl.sourceforge.net/)
43+
44+
## TODO's
45+
46+
This module is (and will probably always be) a 'work in progress'. For now
47+
48+
- Implementing volume control functions.
49+
- 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).
50+
- Get pygame audiorenderer working with the current audioqueue implementation.
51+
- Let the decoder also work for audio-only streams/files.
52+
53+
are on my to-do list, but if you have more suggestions, feel free to open up an issue with a feature request.
54+
55+
## API reference
56+
57+
Further documentation, including an API reference, can be found [here](https://dschreij.github.io/python-mediadecoder).
58+
59+
## License
60+
61+
Like moviepy, this module is licensed under the MIT license:
62+
63+
The MIT License (MIT)
64+
Copyright (c) 2016 Daniel Schreij
65+
66+
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:
67+
68+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
69+
70+
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.
71+
72+
73+
74+
75+

copyright

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2011-2016 Twitter, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

mediadecoder/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
__version__ = "0.1.1"
2+
__author__ = "Daniel Schreij"
3+
__license__ = "MIT"
4+
5+
from mediadecoder.states import *
6+
from mediadecoder.decoder import Decoder
7+
from mediadecoder.timer import Timer
8+
9+
__all__ = ['Decoder','Timer']

0 commit comments

Comments
 (0)