Giter Club home page Giter Club logo

bvplayer's Introduction

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 - [email protected]

Readme inspired by tkvideo

bvplayer's People

Contributors

jwcarlson01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bvplayer's Issues

bvPlayer

Hi, I was trying it .How can I stop the video ?
Is it possible to put it i a tkinter frame and played & stopped by command button ?

Thank you !

Import Error --- Libcblas.so.3

Hi,

i have also an import error. running it on a raspbian system.

Error:
from bvPlayer import bvPlayer
File "/usr/local/lib/python3.9/dist-packages/bvPlayer/init.py", line 1, in
from .bvPlayer import bvPlayer
File "/usr/local/lib/python3.9/dist-packages/bvPlayer/bvPlayer.py", line 2, in
from . import VideoPlayer
File "/usr/local/lib/python3.9/dist-packages/bvPlayer/VideoPlayer.py", line 1, in
import cv2
File "/usr/local/lib/python3.9/dist-packages/cv2/init.py", line 181, in
bootstrap()
File "/usr/local/lib/python3.9/dist-packages/cv2/init.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

Temp file issue

The temp files generated do not get deleted and remain in the temp folder in appdata.

Doesn't even import. Am I stupid and missing something obvious or what?

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    from bvPlayer import bvPlayer
  File "/home/runner/yt/venv/lib/python3.8/site-packages/bvPlayer/__init__.py", line 1, in <module>
    from .bvPlayer import bvPlayer
  File "/home/runner/yt/venv/lib/python3.8/site-packages/bvPlayer/bvPlayer.py", line 2, in <module>
    from . import VideoPlayer
  File "/home/runner/yt/venv/lib/python3.8/site-packages/bvPlayer/VideoPlayer.py", line 1, in <module>
    import cv2
  File "/home/runner/yt/venv/lib/python3.8/site-packages/cv2/__init__.py", line 8, in <module>
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.