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 extension that provides bindings to WebRTC M92

This project follows the W3C specification with some modifications and additions to make it work better with Python applications, with useful APIs like programmatic audio and video.

Il'ya 104 Dec 26, 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
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
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
Python retagging utility for mkv files using mkvmerge.

pyretag A python script to retag mkv files. Setting Up pip install pyfiglet pip install rich Move the mkv files to input folder.

25 Dec 04, 2022
Become a virtual character with just your webcam!

Become a virtual character with just your webcam!

Rich 300 Jan 03, 2023
A python program which converts images and video into excel spreadsheets.

image2excel A program which converts images and video into Excel spreadsheets. Usage examples can be found in examples Videos can take a long time to

Oscar Peace 2 Aug 09, 2021
Search a video semantically with AI.

Which Frame? Search a video semantically with AI. For example, try a natural language search query like "a person with sunglasses". You can also searc

David Chuan-En Lin 1 Nov 06, 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
Adblocker for movie subtitles.

SubAdBlock Adblocker for movie subtitles. Usage Place "main.py" and "config.conf" in directory with subtitles and run "main.py". It will automatically

Marko Živić 1 Jan 09, 2022
This application makes a webrtc video call with jitsi meet signaling

gstreamer-jitsi-meet This application makes a webrtc video call with jitsi meet signaling. Other end can be any jitsi meet app or web app. It doesn't

Linh 7 Apr 26, 2022
Rune - a video miniplayer made with Python.

Rune - a video miniplayer made with Python.

1 Dec 13, 2021
Automatic video generator for local news

Automatic video generator for local news

Gabriel Monteiro 2 Jan 11, 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
Wonkey - an open source programming language for the creation of cross-platform video games

Wonkey Programming Language Wonkey is an open source programming language for the creation of cross-platform video games, highly inspired by the “Blit

Wonkey Coders 110 Nov 09, 2022
Video stream image stacking -- live version

video stream image stacking v2 -- live version A very simple streamed video image stacking code! Version 2.1 left mouse click to select a small region

Chakravarthy Mathiazhagan 1 Jan 03, 2022
A Telegram bot to convert videos into x265/x264 format via ffmpeg.

Video Encoder Bot A Telegram bot to convert videos into x265/x264 format via ffmpeg. Configuration Add values in environment variables or add them in

Adnan Ahmad 82 Jan 03, 2023
MoviePy is a Python library for video editing, can read and write all the most common audio and video formats

MoviePy is a Python library for video editing: cutting, concatenations, title insertions, video compositing (a.k.a. non-linear editing), video processing, and creation of custom effects. See the gall

10k Jan 08, 2023
Code for the manim-generated scenes used in 3blue1brown videos

Code for the manim-generated scenes used in 3blue1brown videos

Grant Sanderson 4.1k Jan 09, 2023
An easy to use GUI based video to image sequence converter (and vice versa).

Vdo & Img Conversion Tools This is a quick conversion tool made with python that can save you a lot of time. With this tool you can extract image sequ

Akash Bora 3 Sep 18, 2022