Skip to main content

Simple and fast library to convert midi files to video

Project description

Midi2Vid - Simple and Fast Midi to Video Converter

Midi to video converter. This program renders the notes of a midi file to a video. The renderer is built on top of the pygame library and uses multiple processes to generate the frames of the video. It then uses ffmpeg to convert the frames to a video. It also uses the fluidsynth library to render the midi file to a wav file.

Example

Installation

Install from github using pip:

pip install git+https://github.com/pianoviz/midi2vid.git

Build with docker:

docker build -t midi2vid-base .
docker run --rm -v $(pwd):/app midi2vid-base -i data/example.mid -o your_output.mp4

Build from source:

git clone https://github.com/pianoviz/midi2vid.git
cd midi2vid
pip install -e .

Usage

midi2vid -i <input_midi_file> -o <output_video_file>

Options

-i, --input: Input midi file
-o, --output: Output video file
--config: Path to the configuration file (default: config/default.json)

Configuration

The configuration file is a JSON file that specifies various parameters for the video generation. Here is an example configuration file:

{
  "soundfont_path": "data/soundfont.sf2",
  "max_note_length": 50,
  "n_processors": 4,
  "screen_width": 1920,
  "screen_height": 1080,
  "bpm": 120,
  "fps": 30,
  "speed": 200,
  "white_note_color": [255, 255, 255],
  "black_note_color": [49, 49, 49],
  "background_color": [43, 43, 43],
  "octave_lines_color": [92, 92, 92],
  "note_color": [179, 44, 49],
  "dark_note_color": [113, 34, 36],
  "right_note_color": [168, 255, 145],
  "left_note_color": [176, 202, 229],
  "dark_right_note_color": [118, 208, 68],
  "dark_left_note_color": [124, 142, 151],
  "estimate_hands": false
}

The estimate_hands parameter is experimental and is used to estimate the hand positions based on the notes played. It is currently under development and may not work as expected.

Example

There is an example midi file in the data directory. You can run the following command to generate a video from the example midi file:

midi2vid -i data/example.mid -o example.mp4

Dependencies

  • pygame
  • ffmpeg
  • fluidsynth

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

midi2vid-0.0.4.tar.gz (89.8 kB view details)

Uploaded Source

Built Distribution

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

midi2vid-0.0.4-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file midi2vid-0.0.4.tar.gz.

File metadata

  • Download URL: midi2vid-0.0.4.tar.gz
  • Upload date:
  • Size: 89.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for midi2vid-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ca0c6af8bbe21d2758ba48b4c66c4e2b28e684c8a6d9d1adfa28baef5a66a3b2
MD5 2c6ac3af20ebd3ee6443b2aae1bda38b
BLAKE2b-256 d08bc4b0cb5574b4205ae85c132c20992ffcd29cd95eb6c0951a78cd577138cd

See more details on using hashes here.

File details

Details for the file midi2vid-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: midi2vid-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for midi2vid-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b3dfde16c48fb5f8b38c1274ac7dc0160e7f7ed9e07d1f0a4acdac7252dcf76a
MD5 570ad1efc1fa54d9653a733a6716bb0e
BLAKE2b-256 1476c6cce7167a356a14251d58d674f293644a67ea8f608d87bbde46a0bedf61

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