A cython implementation of an ffmpeg based player.
Project description
FFPyPlayer is a python binding for the FFmpeg library for playing and writing media files.
For more information: http://matham.github.io/ffpyplayer/index.html
To install: http://matham.github.io/ffpyplayer/installation.html
Usage example
Playing a file:
>>> from ffpyplayer.player import MediaPlayer
>>> import time
>>> player = MediaPlayer(filename)
>>> val = ''
>>> while val != 'eof':
... frame, val = player.get_frame()
... if val != 'eof' and frame is not None:
... img, t = frame
... # display img
Writing a video file:
>>> from ffpyplayer.writer import MediaWriter
>>> from ffpyplayer.pic import Image
>>> w, h = 640, 480
>>> # write at 5 fps.
>>> out_opts = {'pix_fmt_in':'rgb24', 'width_in':w, 'height_in':h,
... 'codec':'rawvideo', 'frame_rate':(5, 1)}
>>> writer = MediaWriter('output.avi', [out_opts])
>>> # Construct image
>>> size = w * h * 3
>>> buf = bytearray([int(x * 255 / size) for x in range(size)])
>>> img = Image(plane_buffers=[buf], pix_fmt='rgb24', size=(w, h))
>>> for i in range(20):
... writer.write_frame(img=img, pts=i / 5., stream=0)
Converting images:
>>> from ffpyplayer.pic import Image, SWScale
>>> w, h = 500, 100
>>> size = w * h * 3
>>> buf = bytearray([int(x * 255 / size) for x in range(size)])
>>> img = Image(plane_buffers=[buf], pix_fmt='rgb24', size=(w, h))
>>> sws = SWScale(w, h, img.get_pixel_format(), ofmt='yuv420p')
>>> img2 = sws.scale(img)
>>> img2.get_pixel_format()
'yuv420p'
>>> planes = img2.to_bytearray()
>>> map(len, planes)
[50000, 12500, 12500, 0]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ffpyplayer-4.2.0.tar.gz
(71.7 kB
view hashes)
Built Distributions
Close
Hashes for ffpyplayer-4.2.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e2e12f44c3bb580d0fd08875a75508b380c6fbead50a59d406b811fc65e5f77 |
|
MD5 | 7e5963f2c8058e6ab2498c5953ef2995 |
|
BLAKE2b-256 | 24e9288f6f86e2752e4aa490a7a2c819309357f3115185cdf5f25e59a86f8964 |
Close
Hashes for ffpyplayer-4.2.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ec21e3e5a0d69084c58d0f04940257c6f055f261ea4fbfa042c575c275ed3d0 |
|
MD5 | 192bfb1e9632a2484615725a4075bc2d |
|
BLAKE2b-256 | c74e9f37a2da4f6404abe73f1731321f1b46a90e86b34d9bcefe636fd50d9ab7 |
Close
Hashes for ffpyplayer-4.2.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae0a876df7f3f7bb77af41a004baf5be089c3dca94bc05e4d0f520f99c737ca8 |
|
MD5 | 9557c04656a463458d41f52573037570 |
|
BLAKE2b-256 | c86a86b08df209e2abb8e8cedca612add8b8d13240bcf7495f3871d9af36a71b |
Close
Hashes for ffpyplayer-4.2.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e8262e291e8e837a2d7923486c68e556ddc962176e2be93a089b843bea2dc6c |
|
MD5 | 812228f041d60b0e66d90e150fe85d6c |
|
BLAKE2b-256 | 69df6020e7ad6bf257677e98b83e9d9986badb9204692309366b2bb74f6c509f |
Close
Hashes for ffpyplayer-4.2.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d0b3a1937eaeb635c3a6758371dc38e6d7b4808ac8becf6878fdfb2aadbdc44 |
|
MD5 | 2987fb55ec3872b7a3b903b5ba95c430 |
|
BLAKE2b-256 | 1657d018c12b5baddd1dd4a1e51cb7f2a0953097ac47fca44da1a4fc7279c86d |
Close
Hashes for ffpyplayer-4.2.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e74637db13206871169b9878b8f2e16543d7be862464e711763b867a5b999e18 |
|
MD5 | 13bdef3387a0d760ef7b7ba6df8db59d |
|
BLAKE2b-256 | 4b13c85a57d054564bd403ed16d3b2691fead0d7ccf49a154aff46c65abe0b4b |
Close
Hashes for ffpyplayer-4.2.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 660bf825813322bfe741ed0ece3fd03cbfae42a795547811e39708b6a7bc8d80 |
|
MD5 | 9c24c84a3b3eae9fd53a6eb9bb60b49b |
|
BLAKE2b-256 | 50e2adb08ed0cd0fb3596fe6d8e75b0b04e43cf72ad0ca268c7e22730d816abf |
Close
Hashes for ffpyplayer-4.2.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6005a746f0763395b18876b539528d68b2b869318ced3012d004277d5cba9c0 |
|
MD5 | 49062db9110a955b6eb1158c8b15d4e5 |
|
BLAKE2b-256 | 9ae8cd2b89d5cdc7a93d303f45e2393b147e7e63be4d8cf335be28f09628067d |
Close
Hashes for ffpyplayer-4.2.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b77282a05fabff44a75381b96d369e2058e50eda8533e7543b034fc9b32e70f4 |
|
MD5 | 881392f82fb353bdd0d31a2ca35e5882 |
|
BLAKE2b-256 | 2a2d5b151075b6714b17aad7b8b4a0eddc3cbbde16e482e648a4962cefb9f460 |
Close
Hashes for ffpyplayer-4.2.0-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de4a989dd4a57bad4dc8a9a808c6c2a60fd9cd1598c57b1bffe4c657f398d0fd |
|
MD5 | a43d3be89f46dcb4f6cc18bc8ef8095f |
|
BLAKE2b-256 | 45593698ce8a994f0e04f59dc1bf035e276458be5d74e52c408681b4a6262fa9 |
Close
Hashes for ffpyplayer-4.2.0-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9059a77bb5b14d19f002835ed5f13d4bd5ab62ed092b291a148cf021f918eb96 |
|
MD5 | cb4c5b6e502d4a1bd020899212b87bf8 |
|
BLAKE2b-256 | 8832a97b96170d0d77fb89a77cbd17dcf7d23520609596b24b846ae22b26cb4f |
Close
Hashes for ffpyplayer-4.2.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17940e393e847b12af94fa728ec27d46a290e38306518668ee448ff5498838aa |
|
MD5 | 5da15242d26224bd201dccf8ad847518 |
|
BLAKE2b-256 | 1d58edc23d10e558f681b533e52092d27ff179cf1009f2a7150598c5c61a381b |