Inject mp4 videos into your pygame surface
Project description
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 :))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file video-injection-pygame-0.0.3.tar.gz
.
File metadata
- Download URL: video-injection-pygame-0.0.3.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f85a71bafc72e20c7d65c96a2dae23d8e8e9229671c9d646aad803399ca3785b |
|
MD5 | 6173525403f85249a192ba2e5761089e |
|
BLAKE2b-256 | a75ea532af79114648b4c66704661749e2af3e77acfd9f030d251b5bda49bdd5 |
File details
Details for the file video_injection_pygame-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: video_injection_pygame-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff2e82e5c44267db6c840e83546b1611c5c1c09b968c9f064a0ec08c9e39d40c |
|
MD5 | 0b8abf24d69599da1e6a0c0d187e17f8 |
|
BLAKE2b-256 | fea8183283e203f3e7255ad5a8ccf2d8ef37b7a73dca451be5d4f6a943763d84 |