A cython implementation of an ffmpeg based player.
Project Links
Meta
Author: Matthew Einhorn
Classifiers
License
- OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Topic
- Multimedia :: Video
- Multimedia :: Video :: Display
- Multimedia :: Sound/Audio :: Players
- Multimedia :: Sound/Audio :: Players :: MP3
Programming Language
- Python :: 3.7
- Python :: 3.8
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
Operating System
- MacOS :: MacOS X
- Microsoft :: Windows
- POSIX :: BSD :: FreeBSD
- POSIX :: Linux
Intended Audience
- Developers
FFPyPlayer is a python binding for the FFmpeg library for playing and writing media files.
For more information: https://matham.github.io/ffpyplayer/index.html
To install: https://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]
4.5.3
Jun 11, 2025
4.5.2
Oct 16, 2024
4.5.1
Oct 08, 2023
4.5.0
Apr 01, 2023
4.4.0
Feb 11, 2023
4.3.5
Mar 29, 2022
4.3.4
Mar 22, 2022
4.3.3
Mar 18, 2022
4.3.2
Oct 14, 2020
4.3.1
Feb 26, 2020
4.3.0
Nov 14, 2019
4.2.0
May 17, 2019
4.1.0
Jul 10, 2018
4.0.1
Jul 12, 2017
4.0.0
Jul 22, 2016
Wheel compatibility matrix
Files in release
ffpyplayer-4.5.3-cp310-cp310-macosx_10_13_universal2.whl (36.5MiB)
ffpyplayer-4.5.3-cp310-cp310-macosx_10_13_x86_64.whl (19.4MiB)
ffpyplayer-4.5.3-cp310-cp310-macosx_11_0_arm64.whl (17.2MiB)
ffpyplayer-4.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (26.5MiB)
ffpyplayer-4.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28.3MiB)
ffpyplayer-4.5.3-cp310-cp310-win_amd64.whl (58.2MiB)
ffpyplayer-4.5.3-cp311-cp311-macosx_10_13_universal2.whl (36.5MiB)
ffpyplayer-4.5.3-cp311-cp311-macosx_10_13_x86_64.whl (19.4MiB)
ffpyplayer-4.5.3-cp311-cp311-macosx_11_0_arm64.whl (17.2MiB)
ffpyplayer-4.5.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (26.8MiB)
ffpyplayer-4.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28.6MiB)
ffpyplayer-4.5.3-cp311-cp311-win_amd64.whl (58.2MiB)
ffpyplayer-4.5.3-cp312-cp312-macosx_10_13_universal2.whl (36.5MiB)
ffpyplayer-4.5.3-cp312-cp312-macosx_10_13_x86_64.whl (19.4MiB)
ffpyplayer-4.5.3-cp312-cp312-macosx_11_0_arm64.whl (17.2MiB)
ffpyplayer-4.5.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (26.8MiB)
ffpyplayer-4.5.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28.6MiB)
ffpyplayer-4.5.3-cp312-cp312-win_amd64.whl (58.2MiB)
ffpyplayer-4.5.3-cp313-cp313-macosx_10_13_universal2.whl (36.5MiB)
ffpyplayer-4.5.3-cp313-cp313-macosx_10_13_x86_64.whl (19.4MiB)
ffpyplayer-4.5.3-cp313-cp313-macosx_11_0_arm64.whl (17.2MiB)
ffpyplayer-4.5.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (26.8MiB)
ffpyplayer-4.5.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28.5MiB)
ffpyplayer-4.5.3-cp313-cp313-win_amd64.whl (58.2MiB)
ffpyplayer-4.5.3-cp39-cp39-macosx_10_13_universal2.whl (36.5MiB)
ffpyplayer-4.5.3-cp39-cp39-macosx_10_13_x86_64.whl (19.4MiB)
ffpyplayer-4.5.3-cp39-cp39-macosx_11_0_arm64.whl (17.2MiB)
ffpyplayer-4.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (26.6MiB)
ffpyplayer-4.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28.3MiB)
ffpyplayer-4.5.3-cp39-cp39-win_amd64.whl (58.2MiB)
ffpyplayer-4.5.3.tar.gz (87.0KiB)
No dependencies