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
Extracting frames from video and create video using frames

Extracting frames from video and create video using frames This program uses opencv library to extract the frames from video and create video from ext

1 Nov 19, 2021
A GUI based datamoshing apllication for everyone! Apply this glitch to your videos and gifs. Supports all video formats!

A GUI based datamoshing apllication for everyone! Apply this glitch to your videos and gifs. Supports all video formats!

Akascape 131 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
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
OpenShot Video Editor is an award-winning free and open-source video editor for Linux, Mac, and Windows, and is dedicated to delivering high quality video editing and animation solutions to the world.

OpenShot Video Editor is an award-winning free and open-source video editor for Linux, Mac, and Windows, and is dedicated to delivering high quality v

OpenShot Studios, LLC 3.1k Jan 01, 2023
Splat a video into a mosaic by sampling a frame at regular intervals

Splat a video into a mosaic by sampling a frame at regular intervals. Useful for seeing the changes over time of an entire video or movie.

Ryan Fox 4 Oct 16, 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
Docker container to expose a local RTMP, RTSP, and HLS stream for all your Wyze cameras including v3

Docker container to expose a local RTMP, RTSP, and HLS stream for all your Wyze cameras including v3. No Third-party or special firmware required.

1.2k Jan 07, 2023
High-performance cross-platform Video Processing Python framework powerpacked with unique trailblazing features :fire:

Releases | Gears | Documentation | Installation | License VidGear is a High-Performance Video Processing Python Library that provides an easy-to-use,

Abhishek Thakur 2.6k Dec 28, 2022
Tiny python video cutter

tiny_python_video_cutter Source code based on a discussion in StackOverflow Setup project in Pycharm: Configure virtual env in Pycharm. You are done w

Truong 2 May 28, 2022
Media player custom component which works with MQTT.

Media player custom component which works with MQTT. I designed this to specifically work with a ESP32 which i used to control a speakercraft amp.

2 Feb 10, 2022
Simple VLC-based media player that can play multiple videos at the same time

Screenshots About Simple VLC-based media player that can play multiple videos at the same time. You can play as many videos as you like, the only limi

161 Jan 05, 2023
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
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
Uncompress DEFLATE streams in pure Python

stream-deflate Uncompress DEFLATE streams in pure Python. Work in progress. This README serves as a rough design spec. Installation pip install stream

Michal Charemza 7 Oct 13, 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
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
Streamlink is a CLI utility which pipes video streams from various services into a video player

Streamlink is a CLI utility which pipes video streams from various services into a video player

8.2k Dec 26, 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
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