Skip to main content

Video playback in Python

Project description

pyvidplayer2 (please report all bugs!)

Introducing pyvidplayer2, the successor to pyvidplayer. It's better in pretty much every way, and finally allows an easy and reliable way to play videos in Python.

All the features from the original library have been ported over, with the exception of alt_resize(). Since pyvidplayer2 has a completely revamped foundation, the unreliability of set_size() has been quashed, and a fallback function is now redundant.

Features (tested on Windows)

  • Easy to implement (4 lines of code)
  • Fast and reliable
  • Adjust playback speed
  • No audio/video sync issues
  • Subtitle support (.srt)
  • Play multiple videos in parallel
  • Built in GUI
  • Support for Pygame, Pyglet, Tkinter, and PyQT6
  • Can play all ffmpeg supported video formats
  • Post process effects
  • Webcam feed

Installation

pip install pyvidplayer2

Note: FFMPEG (just the essentials is fine) must be installed and accessible via the system PATH. Here's an online article on how to do this (windows): https://phoenixnap.com/kb/ffmpeg-windows.

Quickstart

Refer to the examples folder for more basic guides, and documentation.md contains more detailed information.

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 True:
    key = None
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            vid.close()
            pygame.quit()
            exit()
        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/plays 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) # around 60 fps

Potential Features (help welcome)

  • Stream online videos
  • Support for subtitle formats other than .srt
  • Reverse video playing

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.8.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

pyvidplayer2-0.9.8-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyvidplayer2-0.9.8.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for pyvidplayer2-0.9.8.tar.gz
Algorithm Hash digest
SHA256 085c2a78e90a9793e678551cd0e1612f0961284980963ab32801d51b956a60a0
MD5 88c60ea4ee69e7a53ce9f574e42dbad6
BLAKE2b-256 f4a3a287a642bc90636df63e1b3f3de55273b4ddc48dba85fca7fd29ec9290d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyvidplayer2-0.9.8-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for pyvidplayer2-0.9.8-py3-none-any.whl
Algorithm Hash digest
SHA256 239c7737f61f31f13eb884d5452248326b878d460994d2ede1b06a3c1bec28cf
MD5 862a6a36ee8666a4cb574040e1b5647b
BLAKE2b-256 a42229acd6b4eaa5989dfff5b6d67af3c6b7c664a46816e3d66e1941ce8437bc

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