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 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

  • Integrates easily with Pygame, PygameCE, Pyglet, Tkinter, PySide6, PyQT6, Raylib, or wxPython
  • Full audio support
  • Lean and modular
  • Supports subtitle files
  • 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-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         (for videos in bytes)
av              (required for imageio)
pyglet          (graphics library)
PySide6         (graphics library)
PyQt6           (graphics library)
tkinter         (graphics library, installed as a system 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.32.tar.gz (58.4 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.32-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyvidplayer2-0.9.32.tar.gz
  • Upload date:
  • Size: 58.4 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.32.tar.gz
Algorithm Hash digest
SHA256 665d015dff2d882f2b459b094e922f37bcfa409fdb0e029376a7cc2d9891a4f3
MD5 6a9f3ba6f0fc62a8cbb9a43cbfd157b4
BLAKE2b-256 16fc5b3253ff78cbccd668f18cd391b61021279f7c4052c565ca350635beb46a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvidplayer2-0.9.32.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.32-py3-none-any.whl.

File metadata

  • Download URL: pyvidplayer2-0.9.32-py3-none-any.whl
  • Upload date:
  • Size: 46.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.32-py3-none-any.whl
Algorithm Hash digest
SHA256 945713f1768ce160392b32e5213dd0cd1d362bca93be48828ccfab8808cc1da8
MD5 15ff3bc5bff083b4563486ba7ac5dff2
BLAKE2b-256 6edf4e2bc3c27472a1b2225cd9210388eb1cfa7174e355b90d9facda6be91c45

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvidplayer2-0.9.32-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