LeaPhant / flowabot

Modular Discord bot with fun features including twitch commands and advanced osu! commands. 🌷
MIT License
111 stars 33 forks source link

fix crash when ffmpeg fails during hitsound rendering #65

Open ILW8 opened 2 years ago

ILW8 commented 2 years ago

This just adds a catch to a Promise.all in renderHitsounds() in render_frame.js. Without it, the render would get stuck forever after ffmpeg exits unexpectedly instead of either failing completely or recovering. The specific issue we ran into was with a hitsound audio file that ffmpeg couldn't handle (ogg vorbis inside a .wav container). Command to reproduce the issue: !render https://osu.ppy.sh/beatmapsets/1276314#osu/2651771 strains 60s.

Still testing various maps, will edit to a full PR once I feel confident this doesn't introduce any regressions.

The output from when ffmpeg exited with exit code 1:

Error: Command failed: /path/to/node_modules/ffmpeg-static/ffmpeg <..truncated..>
<..truncated..>
Input #6, wav, from '/tmp/frames/519695412/map/drum-hitclap.wav':
  Metadata:
    encoder         : Slicex
  Duration: 00:00:04.00, bitrate: 92 kb/s
  Stream #6:0: Audio: none (Og[0][0] / 0x674F), 44100 Hz, 2 channels, 128 kb/s
<..truncated..>
Stream mapping:
  Stream #0:0 (pcm_s16le) -> adelay
  Stream #0:0 (pcm_s16le) -> adelay
  Stream #0:0 (pcm_s16le) -> adelay
  <..truncated..>
  Stream #4:0 (pcm_s16le) -> adelay
  Stream #5:0 (pcm_s16le) -> adelay
  Stream #5:0 (pcm_s16le) -> adelay
  Stream #5:0 (pcm_s16le) -> adelay
  Stream #6:0 (?) -> adelay
  dynaudnorm -> Stream #0:0 (pcm_s16le)
Decoder (codec none) not found for input stream #6:0

    at ChildProcess.exithandler (node:child_process:326:12)
    at ChildProcess.emit (node:events:365:28)
    at maybeClose (node:internal/child_process:1067:16)
    at Socket.<anonymous> (node:internal/child_process:453:11)
    at Socket.emit (node:events:365:28)
    at Pipe.<anonymous> (node:net:661:12) {
  killed: false,
  code: 1,
  signal: null,
  cmd: '<..truncated..>',
  stdout: '',
  stderr: '<..truncated..>'
}