Skip to main content

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

TravisCI status Appveyor status Supported Python versions Latest Version on PyPI

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


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.0.0.zip (714.6 kB view details)

Uploaded Source

Built Distributions

ffpyplayer-4.0.0-cp34-cp34m-win_amd64.whl (17.9 MB view details)

Uploaded CPython 3.4m Windows x86-64

ffpyplayer-4.0.0-cp34-cp34m-win32.whl (16.5 MB view details)

Uploaded CPython 3.4m Windows x86

ffpyplayer-4.0.0-cp27-cp27m-win_amd64.whl (17.9 MB view details)

Uploaded CPython 2.7m Windows x86-64

ffpyplayer-4.0.0-cp27-cp27m-win32.whl (16.5 MB view details)

Uploaded CPython 2.7m Windows x86

File details

Details for the file ffpyplayer-4.0.0.zip.

File metadata

  • Download URL: ffpyplayer-4.0.0.zip
  • Upload date:
  • Size: 714.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ffpyplayer-4.0.0.zip
Algorithm Hash digest
SHA256 577c47e57e49056d92b3d1a921918c8aff65ec07d0db7795d3738d8e2c33ce23
MD5 fbe8af8cfa9c3dc5f8c6c57fde7adfa6
BLAKE2b-256 fdba1a32b7b966957a6c39491180acfa058ebcb769ec3ecbdaa0d0a6215b23fa

See more details on using hashes here.

File details

Details for the file ffpyplayer-4.0.0-cp34-cp34m-win_amd64.whl.

File metadata

File hashes

Hashes for ffpyplayer-4.0.0-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 0e62c2020181a74cc1eaa4a83a30ff8f81d33ea272ac688a0f248ec45c0a4084
MD5 a7257046ce1ace84661f2c2763d743dd
BLAKE2b-256 f82db6d091e00aa25cab419948d27a2c7590dee54428dff6ba710406c9e02757

See more details on using hashes here.

File details

Details for the file ffpyplayer-4.0.0-cp34-cp34m-win32.whl.

File metadata

File hashes

Hashes for ffpyplayer-4.0.0-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 8e56e0a45812717c3eff7567f1dbf77093bd025abab1af270b1759ded5628ace
MD5 c6eec3f803aeadfa4cc40e099bdcb999
BLAKE2b-256 7d5b066088b57e9e1c62217925eaef69c3ac6990ee27b4c24cfa602867eb2bee

See more details on using hashes here.

File details

Details for the file ffpyplayer-4.0.0-cp27-cp27m-win_amd64.whl.

File metadata

File hashes

Hashes for ffpyplayer-4.0.0-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 0fe3cbbb1bb6d2af2c806877bb61b881a47b28390c136953b128b21e6f987edc
MD5 892cd61550d020527e3bd536b5dacc6d
BLAKE2b-256 f6e2ec385d973c0ecb6b4a7b18bb795421e589d4f3a9ea432f4ce9107291564f

See more details on using hashes here.

File details

Details for the file ffpyplayer-4.0.0-cp27-cp27m-win32.whl.

File metadata

File hashes

Hashes for ffpyplayer-4.0.0-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 eb67b6e02c187e5e687363f1c14833179188fc28dcda5de7d26bb56e7f80a841
MD5 93482efa26e74cd00aa9a1fa258e5deb
BLAKE2b-256 10882d4900171557ab16bb6886173a90f43498c2c3af1ada5a395270649b35e4

See more details on using hashes here.

Supported by

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