Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

video-injection-pygame-0.0.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

video_injection_pygame-0.0.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file video-injection-pygame-0.0.3.tar.gz.

File metadata

File hashes

Hashes for video-injection-pygame-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f85a71bafc72e20c7d65c96a2dae23d8e8e9229671c9d646aad803399ca3785b
MD5 6173525403f85249a192ba2e5761089e
BLAKE2b-256 a75ea532af79114648b4c66704661749e2af3e77acfd9f030d251b5bda49bdd5

See more details on using hashes here.

File details

Details for the file video_injection_pygame-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for video_injection_pygame-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ff2e82e5c44267db6c840e83546b1611c5c1c09b968c9f064a0ec08c9e39d40c
MD5 0b8abf24d69599da1e6a0c0d187e17f8
BLAKE2b-256 fea8183283e203f3e7255ad5a8ccf2d8ef37b7a73dca451be5d4f6a943763d84

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page