A Python piano video exporter.
Project description
PianoVis 0.2.0
A Python piano video exporter.
Examples:
Quick Start
- Install PianoVis:
pip install piano-vis - Follow this code format:
import pianovis
resolution = (1920, 1080)
fps = 30
offset = 1
vid = pianovis.Video(resolution, fps, offset)
vid.add_midi("midi1.mid")
vid.add_midi("midi2.mid")
vid.set_audio("audio.mp3")
vid.export("video.mp4")
pianovis.Video
pianovis.Video is the main video class which stores all midi and audio files, and exports the final video.
Video.__init__(resolution: Tuple[int, int], fps: int, offset: int) -> None- Initializes video.
resolution: (x, y) pixel resolution of video.fps: FPS (frames per second) of video.offset: Offset (frames) of video from audio. Usually, a value of 1 makes the video look lined up with the audio.decor_surf=None Decoration surface, blitted under the piano.
Video.configure(path: str, value: Any) -> None- Sets an option for the video (read more in the Customization section).
path: Option path.value: Value to set path to.
Video.add_midi(path: str) -> None- Appends path to midi list.
path: Midi file path.
Video.set_audio(path: str) -> None- Sets audio file to path.
path: Audio file path.
Video.preview(resolution: Tuple[int, int] = (1600, 900), show_meta: bool = True) -> None:- Opens a pygame window to preview the animation.
resolution=(1600, 900): Resolution of pygame window.show_meta=True: Show metadata in the corner of window.audio=True: Play audio along preview.
Video.export(self, path: str, multicore: bool = False, max_cores: int = multiprocessing.cpu_count(), notify: bool = False) -> None:- Exports video to path.
path: Path to export (mp4)multicore=False: Use multiple cores to export. Can be faster, but will take more power.max_cores=multiprocessing.cpu_count(): Maximum cores to use. Only relevant if using multicore.notify=False: Sends notification when done exporting. Only works on linux.
Customization
Run Video.configure to change options.
keys.white.gap: Gap (pixels) between white keys.keys.white.color: Color (RGB) of white keys.keys.black.width_fac: Factor of white key width.keys.black.height_fac: Factor of white key height.keys.black.color: Color (RGB) of black keys.blocks.speed: Speed (pixels per second) of blocks.blocks.border: Border width (pixels) of blocks.blocks.color_grad: Color gradient of blocks: ((fac1, hsv1), (fac2, hsv2)...)blocks.color_hue: Hue adjustment (additive) to color.blocks.color_saturation: Saturation adjustment (multiplicative) to color.blocks.color_value: Value adjustment (multiplicative) to color.blocks.color_border: Color (RGB) of border.blocks.rounding: Rounding radius of blocks.blocks.motion_blur: Use motion blur in blocks.blocks.light: Light up blocks when hit. Still in development.
How It Works
- The user adds midis and sets an audio.
- When the user calls
Video.export, a few things happen:- All midis are parsed.
- Single core:
- Each frame is rendered with pygame, saved, and encoded with opencv.
- All temporary files are deleted.
- Multi core:
- Each core is assigned a chunk of frames and renders and saves them.
- Each frame is encoded with opencv.
- All temporary files are deleted.
- The audio is combined with video with ffmpeg.
Extras
Constants (pianovis.constants)
Note: pianovis.BLACK == pianovis.constants.BLACK
- Colors (Normalized HSV)
- Block color gradient presets.
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
piano-vis-0.2.0.tar.gz
(9.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
piano_vis-0.2.0-py3-none-any.whl
(23.3 kB
view details)
File details
Details for the file piano-vis-0.2.0.tar.gz.
File metadata
- Download URL: piano-vis-0.2.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c80fd6df2289be3a498139c17511d47665510f5e574417e1c09ade5f438c8527
|
|
| MD5 |
e8d2e6504233e1958e9afeabea812b54
|
|
| BLAKE2b-256 |
c2e3bd60d675e430af78effe066311c8d42dc49cbb2ea26a4b7bdbdd9e4b241f
|
File details
Details for the file piano_vis-0.2.0-py3-none-any.whl.
File metadata
- Download URL: piano_vis-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33c81c90a5154e028cbecbe18a9964d9a2a423452c289b51359bc8dd8f394b20
|
|
| MD5 |
a2d573aa19acbebf672dffac70ccd646
|
|
| BLAKE2b-256 |
86de5e9af6dba3e0ef28379e155e490e7b4177c91143828d1999c1dc6b50d9f1
|