Skip to main content

A borderless video player with sound

Reason this release was yanked:

Doesn't manage temp files

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

Uploaded Source

Built Distribution

bvPlayer-0.2.4-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bvPlayer-0.2.4.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.2.4.tar.gz
Algorithm Hash digest
SHA256 8eab38a163100e6f2487f03eed01b9147f13b9dc43a7c747d42aaaa85d135987
MD5 22f58aab6ace9565335b8d10c2c0bde1
BLAKE2b-256 5939478ef908a880298ba0eb6f7f39a6caa3a047e1463a2139e9c15ad09feaae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bvPlayer-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 6.5 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.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2f33b5f84f6deba2e2aba6ae8dcd4c93cd84114247c297001d2ae4ee37bfd57b
MD5 4c9c291bf7cfd055214c841607c89f63
BLAKE2b-256 d4eea8dbef76a124bc4043d6aa8321f4a30456bcde9b4613c0f9583a5b594943

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