Skip to main content

PyGame Video Injection

You are probably looking on how to make it so you can easily play videos inside of your pygame project without facing any huge troubles and reinstalling old pygame versions. So here is a great solution for you! only compatable with mp4 files

Now, you can easily create a 'video surface' and simply blit it onto your screen

from video_pygame.video import VideoSurface
vs = VideoSurface(
    video_path='example.mp4',
    position=pygame.Vector2(0, 0,),
    size=(1000, 500)
)

You can move it by changing it's position parameter - vs.position.x = 123

You can check if it is playing or not by checking vs.playing

and to get current frame, just call the object it self - vs()

here are some function the library also has

VideoSurface().play() -> None: start playing video (audio included)
VideoSurface().stop() -> None: stop playing video and reset frame to zero (audio included)
VideoSurface().get_position() -> list: get current position of the video surface

Here is some deeper explanation you dont really have to know

So there is a data folder in the library, when you create a new video surface object it should create a folder inside of this data called what your .mp4 file is named, if it already exists we just leave it as it is. Next we add all of the frames of the video as .jpg files into this new folder, if it was done before already we just leave it as it is again. And last but not least we check if the final result is corrupted, what that means is if all of the frames are in place. If the video has 730 frames, then you can only finish vs' initialization when there is a 'frame730.jpg' file in the folder, if there is not then we clear all of the files currently being there and start initialization all over again and repeat the proccess of creating .jpg files. So thats why it might take some time when creating a new vs object for the first time, but after it has initialized for once, its going to be Way more faster next time you run your code. I am not going to explain how video is being synced with its sound, which is stored as a .wav and converted to pygame.mixer.Sound object, and everything i said is pretty much everything you have to know, though you can also go through the code - i left some notes there but not much really

Thank you for choosing PyGame Video Injection :))

Release files for video-injection-pygame 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for video-injection-pygame 0.0.3
File Size Uploaded
video-injection-pygame-0.0.3.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for video-injection-pygame 0.0.3
File Interpreter ABI Platform
video_injection_pygame-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / video-injection-pygame-0.0.3.tar.gz

Download URL video-injection-pygame-0.0.3.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f85a71bafc72e20c7d65c96a2dae23d8e8e9229671c9d646aad803399ca3785b
BLAKE2b-256 checksum
How to use checksums
a75ea532af79114648b4c66704661749e2af3e77acfd9f030d251b5bda49bdd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / video_injection_pygame-0.0.3-py3-none-any.whl

Download URL video_injection_pygame-0.0.3-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff2e82e5c44267db6c840e83546b1611c5c1c09b968c9f064a0ec08c9e39d40c
BLAKE2b-256 checksum
How to use checksums
fea8183283e203f3e7255ad5a8ccf2d8ef37b7a73dca451be5d4f6a943763d84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page