Skip to content

Add more repo metadata. #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,20 @@ https://phoenixnap.com/kb/ffmpeg-windows.

## Linux
Before running `pip install pyvidplayer2`, you must first install the required development packages.
- Ubuntu/Debian example: `sudo apt-get install build-essential python3-dev portaudio19-dev`
- Ubuntu/Debian example: `sudo apt install build-essential python3-dev portaudio19-dev libjack-jackd2-dev`
- The Python and PortAudio development packages prevent missing Python.h and missing portaudio.h errors, respectively.
- Installing `libjack-jackd2-dev` manually prevents `portaudio19-dev` from downgrading to libjack0 and removing wine etc (<https://bugs.launchpad.net/ubuntu/+source/portaudio19/+bug/132002>).
- In some circumstances, such as if you are using the kxstudio repo with Linux Mint, incompatible packages may be removed (See <https://github.com/anrayliu/pyvidplayer2/issues/36> for the latest updates on this issue):
```
The following additional packages will be installed:
libjack-dev libjack0 libportaudiocpp0
Suggested packages:
jackd1 portaudio19-doc
The following packages will be REMOVED:
libasound2-plugins:i386 libjack-jackd2-0 libjack-jackd2-0:i386 wine-stable wine-stable-i386:i386 winehq-stable
The following NEW packages will be installed:
libjack-dev libjack0 libportaudiocpp0 portaudio19-dev
```

# Quickstart

Expand All @@ -60,7 +72,7 @@ while vid.active:
vid.stop()
elif event.type == pygame.KEYDOWN:
key = pygame.key.name(event.key)

if key == "r":
vid.restart() #rewind video to beginning
elif key == "p":
Expand All @@ -77,7 +89,7 @@ while vid.active:
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()

Expand All @@ -91,7 +103,7 @@ pygame.quit()

```

# Documentation
# Documentation

Documentation also available in repository as documentation.md.

Expand All @@ -107,7 +119,7 @@ Main object used to play videos. Videos can be read from disk or streamed from Y
- ```subs``` - Pass a Subtitle class here for the video to display subtitles.
- ```post_process``` - Post processing function that is applied whenever a frame is rendered. This is PostProcessing.none by default, which means no alterations are taking place.
- ```interp``` - Interpolation technique used when resizing frames. In general, the three main ones are cv2.INTER_LINEAR, which is fast, cv2.INTER_CUBIC, which is slower but produces better results, and cv2.INTER_AREA, which is better for downscaling. There is also cv2.INTER_NEAREST for maximum performance and cv2.INTER_LANCZOS4 for maximum quality. For convenience, entering the interpolation technique as a string will also work. For example, "cubic" will set the interpolation to cv2.INTER_CUBIC automatically.
- ```use_pygame_audio``` - Specifies whether to use Pyaudio or Pygame to play audio. Pyaudio is almost always the best option, so this is mainly only for those with problems installing Pyaudio. Using pygame audio will not allow videos to be played in parallel.
- ```use_pygame_audio``` - Specifies whether to use Pyaudio or Pygame to play audio. Pyaudio is almost always the best option, so this is mainly only for those with problems installing Pyaudio. Using pygame audio will not allow videos to be played in parallel.
- ```reverse``` - Specifies whether to play the video in reverse. Warning: Doing so will load every video frame into memory, so videos longer than a few minutes can temporarily brick your computer. Subtitles are unaffected by reverse playback.
- ```no_audio``` - Set this to true if the given video has no audio track. Setting this to true can also be used to disable existing audio tracks.
- ```speed``` - Float from 0.5 to 10.0 that multiplies the playback speed. Note that speed if for example, speed=2, the video will play twice as fast. However, every video frame will still be processed. Therefore, the frame rate of your program must be at least twice that of the video's frame rate to prevent dropped frames. So for example, for a 24 fps video, the draw method will have to be called at least, but ideally more than 48 times a second to achieve true x2 speed.
Expand Down Expand Up @@ -164,10 +176,10 @@ Main object used to play videos. Videos can be read from disk or streamed from Y
- ```toggle_mute()```
- ```mute()```
- ```unmute()```
- ```set_interp(interp)``` - Changes the interpolation technique. Works the same as interp= during class instantiation.
- ```set_post_func(func)``` - Changes the post processing function. Also works the same post_func= during class instantiation.
- ```set_interp(interp)``` - Changes the interpolation technique. Works the same as interp= during class instantiation.
- ```set_post_func(func)``` - Changes the post processing function. Also works the same post_func= during class instantiation.
- ```get_pos()``` - Returns the current position in seconds.
- ```seek(time, relative=True)``` - Changes the current position in the video. If relative is true, the given time will be added or subtracted to the current time. Otherwise, the current position will be set to the given time exactly. Time must be given in seconds, and seeking will be accurate to one hundredth of a second. Note that
- ```seek(time, relative=True)``` - Changes the current position in the video. If relative is true, the given time will be added or subtracted to the current time. Otherwise, the current position will be set to the given time exactly. Time must be given in seconds, and seeking will be accurate to one hundredth of a second. Note that
frames and audio within the video will not be updated yet after calling seek.
- ```seek_frame(index, relative=False)``` - Seeks to a particular frame instead of a timestamp.
- ```draw(surf, pos, force_draw=True)``` - Draws the current video frame onto the given surface, at the given position. If force_draw is true, a surface will be drawn every time this is called. Otherwise, only new frames will be drawn. This reduces cpu usage, but will cause flickering if anything is drawn under or above the video. This method also returns whether a frame was drawn.
Expand All @@ -184,7 +196,7 @@ VideoPlayers are GUI containers for videos. This seeks to mimic standard video p
- ```loop``` - Whether the contained video will restart after it finishes. If the queue is not empty, the entire queue will loop, not just the current video.
- ```preview_thumbnails``` - Number of preview thumbnails loaded and saved in memory. When seeking, a preview window will show the closest loaded frame. The higher this number is, the more frames are loaded, increasing the preview accuracy, but also increasing initial load time and memory usage. Because of this, this value is defaulted to 0, which turns seek previewing off.

## Attributes
## Attributes
- ```video``` - Same as given argument.
- ```frame_rect``` - Same as given argument.
- ```vid_rect``` - This is the video fitted into the frame_rect while maintaining aspect ratio. Black bars will appear in any unused space.
Expand All @@ -209,7 +221,7 @@ VideoPlayers are GUI containers for videos. This seeks to mimic standard video p

# Subtitles(path, colour="white", highlight=(0, 0, 0, 128), font=pygame.font.SysFont("arial", 30), encoding="utf-8-sig", offset=50)

Object used for handling subtitles. Only supported for Pygame.
Object used for handling subtitles. Only supported for Pygame.

## Arguments
- ```path``` - Path to subtitle file. This can be any file pysubs2 can read, including .srt, .ass, .vtt, and others.
Expand All @@ -231,7 +243,7 @@ Object used for handling subtitles. Only supported for Pygame.
- ```font``` - Same as given argument.
- ```offset``` - Same as given argument.

## Methods
## Methods
- ```set_font(font)```
- ```get_font()```

Expand Down Expand Up @@ -294,4 +306,4 @@ print(pyvidplayer2.get_version_info())
Returns a dictionary with the version of pyvidplayer2, FFMPEG, and Pygame. Version can also be accessed directly
with ```pyvidplayer2.VERSION```.

When there are no suitable exceptions, ```pyvidplayer2.Pyvidplayer2Error``` may be raised.
When there are no suitable exceptions, ```pyvidplayer2.Pyvidplayer2Error``` may be raised.
8 changes: 4 additions & 4 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ VideoPlayers are GUI containers for videos. This seeks to mimic standard video p
- ```loop``` - Whether the contained video will restart after it finishes. If the queue is not empty, the entire queue will loop, not just the current video.
- ```preview_thumbnails``` - Number of preview thumbnails loaded and saved in memory. When seeking, a preview window will show the closest loaded frame. The higher this number is, the more frames are loaded, increasing the preview accuracy, but also increasing initial load time and memory usage. Because of this, this value is defaulted to 0, which turns seek previewing off.

## Attributes
## Attributes
- ```video``` - Same as given argument.
- ```frame_rect``` - Same as given argument.
- ```vid_rect``` - This is the video fitted into the frame_rect while maintaining aspect ratio. Black bars will appear in any unused space.
Expand All @@ -112,7 +112,7 @@ VideoPlayers are GUI containers for videos. This seeks to mimic standard video p

# Subtitles(path, colour="white", highlight=(0, 0, 0, 128), font=pygame.font.SysFont("arial", 30), encoding="utf-8-sig", offset=50)

Object used for handling subtitles. Only supported for Pygame.
Object used for handling subtitles. Only supported for Pygame.

## Arguments
- ```path``` - Path to subtitle file. This can be any file pysubs2 can read, including .srt, .ass, .vtt, and others.
Expand All @@ -134,7 +134,7 @@ Object used for handling subtitles. Only supported for Pygame.
- ```font``` - Same as given argument.
- ```offset``` - Same as given argument.

## Methods
## Methods
- ```set_font(font)```
- ```get_font()```

Expand Down Expand Up @@ -195,6 +195,6 @@ print(pyvidplayer2.get_version_info())
```

Returns a dictionary with the version of pyvidplayer2, FFMPEG, and Pygame. Version can also be accessed directly
with ```pyvidplayer2.VERSION```.
with ```pyvidplayer2.__version__```.

When there are no suitable exceptions, ```pyvidplayer2.Pyvidplayer2Error``` may be raised.
48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[build-system]
requires = ["setuptools", "setuptools_scm", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "pyvidplayer2"
dynamic = ["version"]
description = "Reliable, easy, and fast video playback in Python"
readme = {file = "README.md", content-type = "text/markdown"}
authors = [
{name = "Anray Liu", email = "anrayliu@gmail.com"}
]
requires-python = ">=3.9"
dependencies = [
"numpy",
"opencv-python",
"pygame",
"pysubs2",
"PyAudio"
]
keywords = ["pygame", "video", "playback", "tkinter", "pyqt", "pyglet"]
classifiers = [
"Development Status :: 4 - Beta",

"Intended Audience :: Developers",
"Topic :: Multimedia :: Video",
"Topic :: Multimedia :: Video :: Display",
"Topic :: Software Development :: Libraries :: pygame",
"Topic :: Software Development :: Libraries :: tkinter",
"Topic :: Software Development :: Libraries :: pyglet",
"Topic :: Software Development :: Libraries :: pyqt6",

"License :: OSI Approved :: MIT License",

"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"
]

[tool.setuptools.dynamic]
version = {attr = "pyvidplayer2._version.__version__"}

[project.urls]
Homepage = "https://github.com/anrayliu/pyvidplayer2"
Documentation = "https://github.com/anrayliu/pyvidplayer2/blob/main/documentation.md"
Repository = "https://github.com/anrayliu/pyvidplayer2.git"
Issues = "https://github.com/anrayliu/pyvidplayer2/issues"
16 changes: 7 additions & 9 deletions pyvidplayer2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pyvidplayer2._version import __version__
from subprocess import run

from .post_processing import PostProcessing
Expand All @@ -6,21 +7,21 @@
try:
import tkinter
except ImportError:
pass
pass
else:
from .video_tkinter import VideoTkinter

try:
import PyQt6
except ImportError:
pass
pass
else:
from .video_pyqt import VideoPyQT

try:
import pygame
except ImportError:
pass
pass
else:
pygame.init()

Expand All @@ -32,14 +33,11 @@
try:
import pyglet
except ImportError:
pass
pass
else:
from .video_pyglet import VideoPyglet


VERSION = "0.9.16"


def get_version_info():
try:
pygame_ver = pygame.version.ver
Expand All @@ -51,6 +49,6 @@ def get_version_info():
except FileNotFoundError:
ffmpeg_ver = "not installed"

return {"pyvidplayer2": VERSION,
return {"pyvidplayer2": __version__,
"ffmpeg": ffmpeg_ver,
"pygame": pygame_ver}
"pygame": pygame_ver}
1 change: 1 addition & 0 deletions pyvidplayer2/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.9.17"
29 changes: 23 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from setuptools import setup
from pyvidplayer2 import VERSION
from pyvidplayer2._version import __version__


with open("README.md", 'r') as f:
Expand All @@ -8,20 +8,37 @@

setup(
name="pyvidplayer2",
version=VERSION,
description="Video playback in Python",
version=__version__,
description="Reliable, easy, and fast video playback in Python",
long_description=long_desc,
long_description_content_type = "text/markdown",
author="Anray Liu",
author_email="anrayliu@gmail.com",
license="MIT",
packages=["pyvidplayer2"],
install_requires=["numpy",
"opencv_python",
"pygame",
"pysubs2",
"PyAudio"],
url="https://github.com/ree1261/pyvidplayer2",
url="https://github.com/anrayliu/pyvidplayer2",
platforms=["windows", "linux"],
keywords=["pygame", "video", "playback", "tkinter", "pyqt", "pyglet", "youtube", "stream"]
keywords=["pygame", "video", "playback", "tkinter", "pyqt", "pyglet", "youtube", "stream"],
classifiers = [
"Development Status :: 4 - Beta",

"Intended Audience :: Developers",
"Topic :: Multimedia :: Video",
"Topic :: Multimedia :: Video :: Display",
"Topic :: Software Development :: Libraries :: pygame",
"Topic :: Software Development :: Libraries :: tkinter",
"Topic :: Software Development :: Libraries :: pyglet",
"Topic :: Software Development :: Libraries :: pyqt6",

"License :: OSI Approved :: MIT License",

"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"
]
)