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
Playing videos through S3 buckets (Wasabi, AWS, etc.) through client-side VideoJS player

Playing videos through S3 buckets (Wasabi, AWS, etc.) through client-side VideoJS player without incurring ingress/egree traffic on EC2 Instance.

Syed Umar Arfeen 8 Mar 28, 2022
PyAV is a Pythonic binding for the FFmpeg libraries.

PyAV is a Pythonic binding for the FFmpeg libraries. We aim to provide all of the power and control of the underlying library, but manage the gritty details as much as possible.

PyAV 1.8k Jan 01, 2023
Takes a video as an input and creates a video which is suitable to upload on Youtube Shorts and Tik Tok (1080x1920 resolution).

Shorts-Tik-Tok-Creator Takes a video as an input and creates a video which is suitable to upload on Youtube Shorts and Tik Tok (1080x1920 resolution).

Arber Hakaj 5 Nov 09, 2022
Code from the 2021 Signal Video Superclass

Twilio Video Demo This is the code written during the live Twilio Video demo during Twilio's Signal 2021 Superclass. It creates a simple Video applica

2 Oct 21, 2021
In this project, we will be blurring the background in a live video feed

In this project, we will be blurring the background in a live video feed. This can be further integrated into online meetings, streamings etc.

Hassan Shahzad 2 Jan 06, 2022
Stream-Cli application that allow you to play your favorite movies from the terminal

Stream-Cli application that allow you to play your favorite movies from the terminal

redouane 380 Jan 08, 2023
Automatically segment in-video YouTube sponsorships.

SponsorBlock Auto Segment [Model Download] Automatically segment in-video YouTube sponsorships. Trained on a large dataset of YouTube sponsor transcri

Akmal 7 Aug 22, 2022
Stream anime from kaa.si with python

kaa.si-cli Stream anime using MPV player from kaa.si with python

Muhammad Rovino Sanjaya 52 Dec 24, 2022
video streaming userbot (vsu) based on pytgcalls for streaming video trought the telegram video chat group.

VIDEO STREAM USERBOT ✨ an another telegram userbot for streaming video trought the telegram video chat. Environmental Variables 📌 API_ID : Get this v

levina 6 Oct 17, 2021
A platform which give you info about the newest video on a channel

youtube A platform which give you info about the newest video on a channel. This uses web scraping, a better implementation will be to use the API. BR

Custom components for Home Assistant 36 Sep 29, 2022
Stream deck using Arduino and Python

Stream deck using Arduino and Python This is a little project I started due to the fact that I wanted to stream and didn't want to spend lots on a sim

Tal Cherniavsky 2 Feb 11, 2022
Video-stream - A telegram video stream bot repo

This is a Telegram Video stream Bot. Binary Tech 💫 Features stream videos downl

silentz lk 1 Feb 02, 2022
Video Object Segmentation(VOS) From Zero to HeroVideo Object Segmentation(VOS) From Zero to Hero

Video Object Segmentation(VOS) From Zero to Hero! Goal 1:train a two layers cnn model for vos. Finish! see model.py FFNet for more diteal.(2021.9.30)

1 Oct 22, 2021
TkVideoplayer - This is a simple library to play video files in tkinter.

TkVideoplayer - This is a simple library to play video files in tkinter.

Art/Paul 38 Dec 23, 2022
Python and OpenCV-based scene cut/transition detection program & library.

Video Scene Cut Detection and Analysis Tool Latest Release: v0.5.6.1 (October 11, 2021) Main Webpage: py.scenedetect.com Documentation: manual.scenede

Brandon Castellano 1.8k Jan 02, 2023
This plugin generates json files used by deovr allowing you to play 2d and 3d video's using the player

deovr-plugin This plugin generates json files used by deovr allowing you to play 2d and 3d video's using the player. Deovr looks for an index file /de

10 Sep 29, 2022
Python package to display video in GUI using OpenCV-Python and PySide6

Python package to display video in GUI using OpenCV-Python and PySide6. Introduction cv2PySide6 is a package which provides utility classes and functi

3 Jun 06, 2022
A wrapper around ffmpeg to make it work in a concurrent and memory-buffered fashion.

Media Fixer Have you ever had a film or TV show that your TV wasn't able to play its audio? Well this program is for you. Media Fixer is a program whi

Halit Şimşek 3 May 04, 2022
Youtube as covert-channel - Control systems remotely and execute commands by uploading videos to Youtube

covert-tube A program to control systems remotely by uploading videos to Youtube using Python to create the videos and the listener, emulating some ma

Ricardo Ruiz 101 Nov 01, 2022
This is a tool for making a every day video if you take a picture of you everyday

Face-Everyday-Maker-Studio Description This project is a tool for making a everyday video, which is timelapse video or slides video, of images but for

John A Betancourt G 9 Sep 06, 2022