Skip to main content

A borderless video player with sound

Project description

bvPlayer

A borderless video player for python. Comes with a variety of functions such as audio synchronization, FPS adjustment, video scaling, window dragging, and menu options.

Audio synchronization is done through frame skipping and frame delaying. Fps adjustments is done through randomly selecting frames within small chunks. The user is limited to an approximation of their input fps, this is to make the video look smoother.

Resources

This package was implemented with:

  • opencv, for frame loading from a video file
  • Pillow, for displaying images on tkinter
  • ffpyplayer, for audio synchronization

Installation

  • Download the repository and run setup.py
git clone https://github.com/jwcarlson01/bvPlayer.git
python bvPlayer/setup.py
  • Install from PyPI
pip install bvPlayer

Usage

  • import the bvPlayer package and class
from bvPlayer import bvPlayer
  • call the class with a filename and optional arguments
bvPlayer("file.mp4")

The video will play upon the class declaration.

Optional Arguments

If optional arguments are not specified, the video will default to its orginal fps, (0,0) position on the screen, non-draggable, its original dimensions, and no videoOptions.

  • fps, to change the display fps to a number less than the file fps
fps = float
  • pos, to change the start-up display location on the screen
pos = (int x, int y)
  • draggable, to make the window draggable
draggable = bool
  • dim, to scale the video output to a desired dimension
dim = (int w, int h)
  • videoOptions, to enable options when right clicking the video, includes quit and restart
videoOptions = bool

Example

from bvPlayer import bvPlayer

bvPlayer("file.mp4", draggable = True, fps = 28, dim = (854, 480))

Performance

There are two approaches to playing a video on tkinter, either to pregenerate images in a folder and read those images after onto tkinter, or to dynamically load images and display them at the same time.

bvPlayer uses the dynamic approach. bvPlayer uses opencv to load images into temporary files. These temp files are then read by Pillow to be displayed on tkinter. Naturally there is a heavy performance loss using the dynamic approach. bvPlayer uses one thread to read frames, two threads to write frames to temp files, and one thread to display the video and play the audio.

bvPlayer will run a 1080p video on a low end CPU at 20 fps, while using about 60-100% of the CPU. A 480p video will run at 45 fps, using about 40-80% of the CPU; and a 360p video will run at 65 fps, using about 20-60% of the CPU.

bvPlayer keeps only a small number of frames loaded in RAM, so when running a 1080p video it uses less than 200 MB of RAM.

bvPlayer writes its images to temp files, therefore it uses the disk. Expect at most 5MB/s at 1080p.

Contact

I'm always open for suggestions. View the issues page for issues.

Joshua Carlson - joshuacarlson@cedarville.edu

Readme inspired by tkvideo

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

bvPlayer-0.4.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

bvPlayer-0.4.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file bvPlayer-0.4.0.tar.gz.

File metadata

  • Download URL: bvPlayer-0.4.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.3 tqdm/4.51.0 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.0

File hashes

Hashes for bvPlayer-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f80a655d218786131edb88d6389c4a7f1ff8151e0e34402c828323b7c680a4ac
MD5 a0f6056c49dd0fefadca0827e39f2fb8
BLAKE2b-256 0e8f785f0776e222355004b98563ac551074f2403652adc2c40c4257078852c1

See more details on using hashes here.

File details

Details for the file bvPlayer-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: bvPlayer-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.3 tqdm/4.51.0 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.0

File hashes

Hashes for bvPlayer-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 011d0e58fcdfba2eb54b7b3962abe624809d61b4de298ba82bc3c7393c27bef4
MD5 018fe552480850c214b0d670e61a4c56
BLAKE2b-256 9635e057f90a957b2abfa884567382879502b546fdedc56fbb8663ef62ce1ebe

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