Skip to main content

Video playback in Python

Project description

pyvidplayer2

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

  • Easy to implement
  • Reliable playback
  • Fast load times
  • No audio/video sync issues
  • Low cpu usage
  • Subtitle support
  • Play multiple videos in parallel
  • Built in GUI
  • Support for Pygame, Pyglet, and Tkinter
  • Can play all ffmpeg supported video formats
  • Post process effects

Installation

pip install pyvidplayer2

Note: FFMPEG must be installed and accessible via PATH.

Quickstart

Refer to the examples folder for more basic guides, and docs.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

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.0.tar.gz (10.9 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.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyvidplayer2-0.9.0.tar.gz
  • Upload date:
  • Size: 10.9 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.0.tar.gz
Algorithm Hash digest
SHA256 f5e4639cff950998ac807f7f72be7d5953342e374f0a747621151e547a7c9709
MD5 5cb6b8ee1616f7a760f4c22bc78c6466
BLAKE2b-256 3dccae9e4804ee61ae43c2462f1fe9f2e48effd71539fa01fd9af8427672448b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyvidplayer2-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 536b88f07444cec1fb5536b61898ab7abba1465a98a64bc727fb7dedac3e542c
MD5 215ac13e8eb2799d06c9ea38a9f1ad43
BLAKE2b-256 cb11bd1ee6d09b0225222e20dc12ba170da35ca300a6cd483f31fd13e808fb3f

See more details on using hashes here.

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