Creating a plumber API that generates video mp4

It's reading the binary (the 1 and 0s) directly from disk and returning that.

The "gibberish" is just the browser attempt at representing the binary data as text and failing because, it is, in fact, not text.

If you want to get a file download instead of returning the video directly to be rendered inside the browser, you can do something like this.

...
  # Path to video output
  outfile <- attr(res, "outfile")
  # ???
  plumber::as_attachment(readBin(outfile, "raw", n = file.info(outfile)$size), "video.mp4")
}
1 Like