Skip to main content

A python library which simplifies creating and exporting videos.

Project description

vidmaker

A python library which simplifies creating and exporting videos.

Purpose

vidmaker was created because I wanted to record some of my pygame projects, and I found this to be the most convenient way.

How to use

NOTE: vidmaker uses temporary disk space to store frames. This prevents over usage of memory, but slows it down

Since this is a python library, install it by pip install vidmaker

Currently vidmaker only has one class, Video, making it extremely simple to use.

First, you have to initialize your video with the path you want it to render at the fps and the resolution*

import vidmaker

video = vidmaker.Video(path=".", fps=60, resolution="AUTO")

Then you have to update the video every frame with the image you want it to add to your video.

import pygame
import vidmaker

FPS = 60

WINDOW = pygame.display.set_mode((300, 300))
video = vidmaker.Video(".", FPS)
pygame.display.set_caption("vidmaker test")


def main(window):
    pygame.init()
    clock = pygame.time.Clock()

    while True:
        clock.tick(FPS)
        window.fill((255, 0, 0))
        events = pygame.event.get()
        keys = pygame.key.get_pressed()
        ctrl_pressed = keys[pygame.K_LCTRL] or keys[pygame.K_RCTRL]
        for event in events:
            if event.type == pygame.QUIT:
                pygame.quit()
                return
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_q and ctrl_pressed:
                    pygame.quit()
                    return

        video.update(pygame.surfarray.pixels3d(window))  # THIS LINE
        pygame.display.update()


main(WINDOW)

Once your program finishes, you just have to export your video

video.export()

That's it! You should find your video fully rendered at the given path, but the longer the video, the longer video.export() takes.

Contributing

Contributing is always appreciated! I would love it if anyone was to make a pull request to add another feature or create an issue post. Possible features could be things like an option to use memory instead of disk space, the option to render videos in different formats (only mp4 right now), and many more. If there is enough demand I might add some myself as well. Thanks for the support!

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

vidmaker-1.1.0.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

vidmaker-1.1.0-py3-none-any.whl (15.8 kB view hashes)

Uploaded Python 3

Supported by

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