Skip to main content

Reliable, easy, and fast video playback in Python with integrations for pygame, tkinter, pyglet, and more.

Project description

logo

PyPI Version PyPI Downloads Status Coverage security: bandit Python Version Ask DeepWiki Made with ❤️

Comprehensive video playback library for Python.

This library is under active development. If you encounter a bug or a video that cannot be played, please open an issues page.

Features

  • Drop-in integration with only 4 lines of code
  • Lean and modular dependencies
  • Comprehensive audio, video, and subtitle control
  • Supports almost any codec and container
  • Stream videos from Youtube
  • Frame-by-frame iteration and inspection
  • Built-in video player GUI

Installation

pip install pyvidplayer2

In addition, FFmpeg and FFprobe must be downloaded and accessible via PATH. Windows users can go to the official website to download FFmpeg (includes FFprobe). Add the bin folder location to the PATH environment variable. There's plenty of tutorials online for this. Linux and MacOS users can use their package manager of choice.

Legacy Installations

Versions prior to v0.9.31 have a PyAudio dependency. To build the wheel for it, some system packages must be present. Install them with your package manager before running pip install pyvidplayer2.

  • Ubuntu/Debian: sudo apt install python3-dev libjack-jackd2-dev portaudio19-dev
  • Fedora/RHEL: sudo dnf install python3-devel portaudio-devel
  • MacOS: brew install portaudio

Dependencies

numpy
FFmpeg and FFprobe (binaries, not Python packages)

Still requires one graphics library and one audio library of your choice.

Optional Packages

opencv_python       (efficiency improvements and more features, comes installed)
pygame/pygame-ce    (graphics and audio library, comes installed)
sounddevice         (better audio library, comes installed)
pysubs2             (for subtitles, comes installed)
yt_dlp              (for streaming Youtube videos)
decord              (for videos in bytes, best option)
imageio[pyav]       (for videos in bytes)
pyglet              (graphics library)
PySide6             (graphics library)
PyQt6               (graphics library)
tkinter             (graphics library, installed as a sys package or with Python installer, not pip)
raylib              (graphics library)
wxPython            (graphics library)

Use pip install pyvidplayer2[all] to install all packages required for running the unit tests. Not required or recommended for regular users.

Quickstart

Refer to the examples folder for more basic examples.

Pygame Integration

Refer to the examples folder for integrations with other graphics libraries.

import pygame
from pyvidplayer2 import Video


# Create video object

vid = Video("video.mp4")

win = pygame.display.set_mode(vid.current_size)
pygame.display.set_caption(vid.name)


while vid.active:
    key = None
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            vid.stop()
        elif event.type == pygame.KEYDOWN:
            key = pygame.key.name(event.key)

    if key == "r":
        vid.restart()           # Rewind video to beginning
    elif key == "p":
        vid.toggle_pause()      # Pause/play video
    elif key == "m":
        vid.toggle_mute()       # Mute/unmute video
    elif key == "right":
        vid.seek(15)            # Skip 15 seconds in video
    elif key == "left":
        vid.seek(-15)           # Rewind 15 seconds in video
    elif key == "up":
        vid.set_volume(1.0)     # Max volume
    elif key == "down":
        vid.set_volume(0.0)     # Min volume

    # Only draw new frames, and only update the screen if something is drawn

    if vid.draw(win, (0, 0), force_draw=False):
        pygame.display.update()

    pygame.time.wait(16)


# Close video when done

vid.close()
pygame.quit()

Documentation

To get started quickly, you can browse the many code examples. For more detailed information, read the documentation. If you prefer natural language, try asking DeepWiki. If you still have questions, open an issues page.

Known Bugs

For a list of known bugs, refer to this page. If you see an issue not listed, please open a new issue.

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

pyvidplayer2-0.9.33.tar.gz (62.5 kB view details)

Uploaded Source

Built Distribution

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

pyvidplayer2-0.9.33-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

File details

Details for the file pyvidplayer2-0.9.33.tar.gz.

File metadata

  • Download URL: pyvidplayer2-0.9.33.tar.gz
  • Upload date:
  • Size: 62.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyvidplayer2-0.9.33.tar.gz
Algorithm Hash digest
SHA256 31d5664b74455a31039a6fcaac2002e39a6723085f3db19a3d7bd40966e50ab5
MD5 d3da9c9fb820c05a6a6c44a0cc27cc87
BLAKE2b-256 e2e6987c26f533e075936b05424026bce44e987731c9ea7e04906a2816f9927c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvidplayer2-0.9.33.tar.gz:

Publisher: release.yml on anrayliu/pyvidplayer2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvidplayer2-0.9.33-py3-none-any.whl.

File metadata

  • Download URL: pyvidplayer2-0.9.33-py3-none-any.whl
  • Upload date:
  • Size: 48.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyvidplayer2-0.9.33-py3-none-any.whl
Algorithm Hash digest
SHA256 00888442eecf96aa535729be2f2345c86e4ebd3d4ef39f0c156984a2a87ba86d
MD5 fa70356b2cb88441a97a7eda8d29dc83
BLAKE2b-256 5d6e74b02e1df8c7c50296e88f68ac70944f9bf34673dc6078e9575c89dc572c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvidplayer2-0.9.33-py3-none-any.whl:

Publisher: release.yml on anrayliu/pyvidplayer2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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