Skip to main content

pyvidplayer2

PyPI Version PyPI Downloads Status Coverage security: bandit Python Version from PEP 621 TOML Ask DeepWiki Made with ❤️

Featureful library for embedding videos into Python apps.

The latest version (v0.9.37) is a release candidate. This project currently uses pre-1.0 versioning in the form of 0.9.x. After v1.0, it will follow standard Semantic Versioning.

Features

  • Easy integration: Add a video to an existing app with just 4 lines of code
  • Lightweight: Almost every dependency is optional
  • Feature-rich: Seamless loops, custom playback speed, reverse playback, parallel playback, and more
  • Full audio support: Adjust audio track, output device, volume, and more
  • Full subtitle support: Parse subtitles from files or embedded subtitle tracks
  • Play any format: Supports almost every codec and container, VFR videos, even GIFs
  • YouTube integration: Stream videos and subtitles directly from YouTube
  • Low-level control: Frame-by-frame iteration and inspection
  • High compatibility: Integrates with 7 graphics libraries (some features limited to Pygame)
  • Extra features: Built-in video player GUI, post-processing effects, and webcam features

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)
sounddevice         (better audio library, comes installed)
pysubs2             (for subtitles)
yt_dlp[default]     (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.

Documentation

Refer to this page for detailed information. To get started quickly, you can browse the many code examples. If you prefer natural language, try asking DeepWiki. If you still have questions, open an issues page.

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

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.37.tar.gz (66.3 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.37-py3-none-any.whl (49.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyvidplayer2-0.9.37.tar.gz
  • Upload date:
  • Size: 66.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyvidplayer2-0.9.37.tar.gz
Algorithm Hash digest
SHA256 39b9f5a77892d9a76f025f02e1a10db82b0a91c51ef1c51d184b8c41623f78e4
MD5 c1bdfff7174d822f56fcf7e0828d22d7
BLAKE2b-256 68f7782d1c7e9c43347ee2cc2df4a3f1db9483775386e7da4143bc700e497744

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyvidplayer2-0.9.37-py3-none-any.whl
  • Upload date:
  • Size: 49.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyvidplayer2-0.9.37-py3-none-any.whl
Algorithm Hash digest
SHA256 270ee6a7fc632bee1018d3a4bee4f591ba6ecd5c2b5241387741aff90f5d0334
MD5 74f2d25fb825f60e98bea3056107078a
BLAKE2b-256 dae4118bc40f1cc8f910f406ee4122e97e69b88af051dec51714bc7bede230e3

See more details on using hashes here.

Provenance

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

Release history Release notifications | RSS feed

This release

0.9.37 This release

2 files

0.9.36

2 files

0.9.35

2 files

0.9.34

2 files

0.9.33

2 files

0.9.32

2 files

0.9.31

2 files

0.9.30

2 files

0.9.29

2 files

0.9.28

2 files

0.9.27

2 files

0.9.26

2 files

0.9.25

2 files

0.9.24

2 files

0.9.23

2 files

0.9.22

2 files

0.9.21

2 files

0.9.20

2 files

0.9.19

2 files

0.9.18

2 files

0.9.17

2 files

0.9.16

2 files

0.9.15

2 files

0.9.14

2 files

0.9.13

2 files

0.9.12

2 files

0.9.11

2 files

0.9.10

2 files

0.9.9

2 files

0.9.8

2 files

0.9.7

2 files

0.9.6

2 files

0.9.5

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page