pygamevideo module helps developer to embed videos into their Pygame display

Overview

Pygame Video Player

pygamevideo module helps developer to embed videos into their Pygame display. Audio playback doesn't use pygame.mixer.

Installing

pip install pygamevideo

or just copy-paste pygamevideo.py to your working directory

Usage

import pygame
from pygamevideo import Video

window = pygame.display.set_mode()

video = Video("video.mp4")

# start video
video.play()

# main loop
while True:
  ...

  # draw video to display surface
  # this function must be called every tick
  video.draw_to(window, (0, 0))

  # set window title to current duration of video as hour:minute:second
  t = video.current_time.format("%h:%m:%s")
  pygame.display.set_caption(t)

Dependencies

Reference

class Video(filepath)

Pygame video player class

Parameters

filepath : Filepath of the video source

Methods & Attributes

load(filepath) : Load another video source


release() : Release resources

Related to playback control

play(loop=True) : Starts video playback

  • loop : Is video looped or not

restart() : Restarts already playing video


stop() : Stops video


pause() : Pauses video


resume() : Resumes video


is_playing : Whether the video is playing or not (bool)


is_ended : Whether the video has ended or not (bool)


is_paused : Whether the video is paused or not (bool)


is_ready : Whether the resources and video is ready to play (bool)

Related to audio control

mute() : Mutes audio


unmute() : Unmutes audio


has_audio() : NOT IMPLEMENTED


set_volume(volume) : Sets audio volume

  • volume : Floating number between 0.0 and 1.0

is_muted : Whether the audio is muted or not (bool)


volume : Audio volume (float)

Related to timing control

duration : Length of the video as Time object


current_time : Current time of the video as Time object


remaining_time : Remaining time till the end of the video as Time object


total_frames : Length of the video as frames (int)


current_frame : Current frame of the video (int)


remaining_frames : Remaining frames till the end of the video (int)


seek_time(t) : Jump into a specific time of the video

  • t : Time object
  • t : Representation of time in string, eg: "00:01:05:200" meaning 1 minute, 5 seconds and 200 milliseconds (str)
  • t : Milliseconds (int)

seek_frame(frame) : Jump into a specific frame of the video

  • frame : Frame number (int)

Related to resizing & frame dimensions

get_size() : Returns video size (tuple)


get_width() : Returns video width (int)


get_height() : Returns video height (int)


set_size(size) : Resizes video

  • size : New size (tuple)

set_width(width) : Resizes video

  • width : New width (int)

set_height(height) : Resizes video

  • height : New height (int)

keep_aspect_ratio : Keeps original aspect ratio while resizing the video (bool)

Drawing the video

draw_to(surface, pos) : Draws the video onto the surface. This functions must be called every tick.

  • surface : Destination surface (pygame.Surface)
  • pos : Blitting position (tuple)

get_frame() : Returns the current video frame as pygame.Surface. This function is used by draw_to function, so use only one of both each tick

class Time

Data class used to represent duration and such things by Video class

Owner
Kadir Aksoy
A believer in gravity.
Kadir Aksoy
A Python library that simplifies working with video from soccer matches.

Match Video This is a Python library that simplifies working with video from soccer matches. It allows match video to be selected intuitively by perio

Grant Wenzinger 2 Jul 21, 2022
A script to disable steam servers regionwise. [Works on Windows only]

Csgo-server-blocker A script to disable steam servers regionwise. [Works on Windows only] Dependencies python3.x Usage: pip install requirements.txt I

Aditya Bennur 2 Jun 10, 2022
A python youtube search module

A python youtube search module

Fayas Noushad 4 Dec 01, 2021
A free project by a normal kamenrider fan

DEMONS DRIVER Python + OpenCV demons.py采集原视频中led灯珠颜色,并将结果输出到output文件夹 Arduino + WS2812B 基于FastLED 实现DEMONS驱动器的led面板效果 项目未完成,持续更新中 --------------------

2 Nov 14, 2022
Use ZWO astronomy camera as an IP camera.

ZWO Astronomy Camera as IP Camera Astronomy cameras are known for their high sensitivity and flexibility on whether to have IR pass through and bayer

Yan Wang 9 Oct 15, 2022
Home Assistant custom component for viewing IP cameras RTSP stream in real time using WebRTC technology

WebRTC Camera Home Assistant custom component for viewing IP cameras RTSP stream in real time using WebRTC technology. Based on: Pion - pure Go implem

Alex X 739 Dec 30, 2022
Python Script for Streaming YouTube Videos in VLC Media Player.

Short Description Use this Simple Script to stream YouTube Video to VLC

Sijey 6 May 27, 2021
A pure python media player that can be used in AI media API development.

A pure python media player that can be used in AI media API development.

YDOOK 1 Dec 04, 2021
Your self hosted Youtube media server

The Tube Archivist Your self hosted Youtube media server Core functionality Subscribe to your favourite Youtube channels Download Videos using yt-dlp

Simon 2.1k Dec 31, 2022
A Advanced Anime Theme VC Video Player created for playing vidio in the voice chats of Telegram Groups

Yui Vidio Player A Advanced Anime Theme VC Video Player created for playing vidio in the voice chats of Telegram Groups Demo Setting up Add this Bot t

Achu biju 32 Sep 16, 2021
Lightweight, zero-dependency proxy and storage RTSP server

python-rtsp-server Python-rtsp-server is a lightweight, zero-dependency proxy and storage server for several IP-cameras and multiple clients. Features

Vlad 39 Nov 23, 2022
Video Translation Into Text

2021/12/9 The project has been updated Added a home screen Just drag it onto the screen The final results \ 2021/12/9 项目已更新 添加了主界面 拖到即可 最后结果 \ Using t

10 Mar 12, 2022
Video processing routines for SciPy

scikit-video Video Processing SciKit BETA Video processing algorithms, including I/O, quality metrics, temporal filtering, motion/object detection, mo

Alex Izvorski 119 Dec 27, 2022
Telegram Video Stream

Video Stream An Advanced VC Video Player created for playing video in the voice chats of Telegram Groups And Channel Configs TOKEN - Get bot token fro

mr_lokaman 46 Dec 25, 2022
Add a "flame" effect on each hand's index onto a video stream.

Add a "flame" effect on each hand's index onto a video stream. recording.webm.mov This script is just a quick hack, it's a bit of glue between mediapi

Paul Willot 7 Sep 15, 2022
Repository to create Ascii art in CMD based on video file.

Made to take any file format, and transform it into ascii art, displayed as a video in the cmd. If the cmd formatting is wrong, try zooming a little and remember to make cmd fullscreen. I made my cmd

60 Dec 17, 2022
Video stream recording dockerized server using python/ffmpeg.

Stream Recording Server Video stream recording dockerized server using python/ffmpeg. Usage Configuration Prepare .env file, check .env.example for th

GR 2 Jan 14, 2022
This is an example of building a video Question-Answer system using Jina.

example-video-search This is an example of building a video Question-Answer system using Jina. The index data is subtitle files of YouTube videos. Aft

Jina AI 9 Oct 18, 2022
Image and video quality assessment

CenseoQoE: 视觉感知画质评价框架 项目介绍 图像/视频在编解码、传输和显示等过程中难免引入不同类型/程度的失真导致图像质量下降。图像/视频质量评价(IVQA)的研究目标是希望模仿人类视觉感知系统, 通过算法评估图片/视频在终端用户的眼中画质主观体验的好坏,目前在视频编解码、画质增强、画质监。

Tencent 133 Dec 20, 2022
Streams video from raspberry pi to desktop T1 - Recognizes Faces on client T2

VideoStreamingServer Completed: Streams video from raspberry pi to desktop T1 - Recognizes Faces on client T2 In progress: Change the transmission Pro

1 Dec 06, 2021