Skip to content

akazukin5151/metroani

Repository files navigation

Metroani

status

Programatically create multilingual train announcement animations, Japan style.

example

(From python examples/gif.py, python examples/webm.py)

Features

  • Most essential settings can be customized in a JSON file or through a Python API
  • Script itself can be edited for advanced customization
  • Four built-in themes
    • Metro: Tokyo Metro light theme with line color as accent. Used by Tokyo Metro
    • Yamanote: Dark background for station name. Used by newer JR East lines such as the Yamanote and Joban Lines
    • JR: Gray background and older look with more boxes. Used by other JR East lines such as the Keihin-Tohoku and Chuo Lines
    • Tokyu: Dark background for station name and circles for stations. Used by Tokyu Lines

Examples

The Joban Line using the Yamanote theme examples/joban.py:

yamanote theme

The Keihin-Tohoku Line using the JR theme examples/keihin.py:

jr theme

The Tokyu Den-en-toshi Line using the Tokyu theme examples/den_en_toshi.py:

tokyu theme

Installation

  1. git clone https://github.com/akazukin5151/metroani
  2. cd metroani
  3. pip install -r requirements.txt
  4. (Optional: install gifsicle to compress gifs)
  5. Start by running python examples/webm.py and adjusting settings/gif.json
  6. Or run all examples with ./run_all_examples.sh
  7. Read the settings documentation in settings/README.md

Notes:

  • Running python dev.py will create a video using development/debugging settings (which should be avoided). Best to experiment examples/webm.py and settings/gif.json. See settings/README.md
  • Python 3.9 was used to develop the script, but Python 3.7 (or later) should be fine (as long as it supports from __future__ import annotations).

Usage

Start by running examples/webm.py (more optimized than gif and avi), and adjusting settings/gif.json. Line 21 controls the duration of the clip that is generated.

The basic workflow for a clean build is:

  1. Write the settings in either JSON or Python
  2. For JSON, use all_settings_from_json() to convert the JSON setting file into Python settings objects
  3. For Python, directly instantiate the settings objects. Use rgb() to convert 0-255 RGB values to 0-1 values required by gizeh.
  4. (Optional: edit the script itself, for advanced users)
  5. Pass those settings objects into make_video(), which returns a MoviePy clip
  6. (Optional: edit the MoviePy clip however you want)
  7. Write the MoviePy clip into a file (see their manual)

It is encouraged to edit the script, especially the Themes classes

License

The code is licensed under the Mozilla Public License v2, but it does not apply to any content. Any content you create with this script is fully owned by you, and you have the full copyright over them.

Credits

Inspired by and external links: