PL

← Shorts

Dokumentacja — Shorts

Shorts

jumphp/shorts: vertical videos (TikTok, Shorts, Reels) made from a JumPHP scene: melodies played by collisions, the sound mixed offline, timed captions; bin/jumphp video:make renders the frames and the MP4.

  • Recorder: note($time, $freq, $length, $wave, $volume) plays a note now (live) and keeps it for the mix while a video is made. Live, voices are made at half the sample rate, a few ms per frame (pump() once per frame, warm() queues the notes a scene will play): no hitch at a bounce.
  • Voice: the voices (pluck, bell, marimba, sine, pad, drop, meow, purr), generated; Voice::wav() for live, Voice::render() for the film.
  • Melody: Melody::fromString('E4 E4 F4 G4'), fromMidi($file), next() is the next note's frequency.
  • Mixer: the notes mixed into a WAV of the video's length (done by video:make).
  • Sprites and Quality: for a game played live on a phone. Sprites::disc() / glow() / rect() draw a disc, a halo or a rotated rectangle from a texture made once (one copy() instead of one fillRect per scan line of the HD renderer); Quality::begin($r, $recorder->isRecording()), Quality::frame($r) once per frame (hd at most 3 on a phone, one step lighter when the frame rate falls under ~45 fps), Quality::$live false while a film is rendered (nothing changes there). JUMPHP_QUALITY=0|1|2 fixes the level.
  • Draw: ring() with a gap, arc(), trail().
  • Captions: timed text over the video: Captions::fromList($params['captions']), $captions->render($r, $font, $time, $w, $h).
bin/jumphp video:make <game> --template rings --seconds 30 --seed 7 --count 3 \
    --caption "Wait for it@2-5@middle@pop" --caption "Follow for more@20-@bottom@box"

The whole method, the templates and the IDE's Video Preview: docs/video-maker.md of JumPHP.

Shorts Samouczek