Skip to main content

A Python library for rendering code videos

Project description

This repository is used to render and generate videos of input code, with the video perspective following the cursor movement.

Tip: Use manim for animation rendering. Please ensure that manim can run properly before use.

This repository provides CodeVideo, which you can use to create a video object. The parameters are as follows:

CodeVideo(
    # -------------------------------------------------- video name --------------------------------------------------
    video_name: str = "CodeVideo", 

    # ----------------------------------------------------- code -----------------------------------------------------
    code_string: str = None,
    code_file: str = None,
    font: str = 'Consolas',
    language: str = None, 

    # --------------------------------------------------- interval ---------------------------------------------------
    interval_range: tuple[Annotated[float, Field(ge=0.2)], Annotated[float, Field(ge=0.2)]] = (0.2, 0.4), 

    # ---------------------------------------------------- camera ----------------------------------------------------
    camera_floating_maximum_value: Annotated[float, Field(ge=0)] = 0.1,
    camera_move_interval: Annotated[float, Field(ge=0)] = 0.1,
    camera_move_duration: Annotated[float, Field(ge=0)] = 0.5,

    # ---------------------------------------------------- screen ----------------------------------------------------
    screen_scale: float = 0.3
    )

This library uses validate_call from pydantic, which automatically checks the parameter types when you pass them in to ensure correctness.

Please feel free to use it!


You can use the render method on the CodeVideo object to generate the video, and you can check the save location of the video in the terminal.

Example:

from CodeVideoRenderer import *
video = CodeVideo(code_string="print('Hello World!')", language='python')
video.render()

Tip: Although language will be automatically recognized, it may sometimes be incorrect, so it is recommended to specify it.

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

codevideorenderer-1.0.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codevideorenderer-1.0.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file codevideorenderer-1.0.2.tar.gz.

File metadata

  • Download URL: codevideorenderer-1.0.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for codevideorenderer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 eafd10367d410dbfdad46a7c2bbacf05afe437329f6900c9673e390fc158550d
MD5 55bfb2068d5eac2b3eb7530110dc50e8
BLAKE2b-256 b05a7796cc1193fafab28045a14a2e847ad0260faf24c2fe7dd138b9f9cc2537

See more details on using hashes here.

File details

Details for the file codevideorenderer-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for codevideorenderer-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dbff14fe1cca54c8552f64b9419ba2b72c6e9317527f24f5544956ce1531d144
MD5 f2a40983310d28483c328e28da1d51d2
BLAKE2b-256 24018da4273ea371b5b65ac1b571690f8270aa53bcf7690ed8cd1d02d2f93ca8

See more details on using hashes here.

Supported by

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