Skip to content
Discussion options

You must be logged in to vote

This is happening because Method A (Bun.spawn) routes the data through the JavaScript runtime, whereas Method B ($) uses a direct OS-level pipe.

The Technical Difference

  • Bun.spawn Piping: When you pass stdin: ffmpeg.stdout, Bun currently treats ffmpeg.stdout as a JavaScript ReadableStream. This means every chunk of video data is allocated in JS memory, passed through the event loop, and then written to ffplay. For high-throughput binary data (like ffmpeg), the Garbage Collector cannot keep up with the allocation rate, leading to the OOM and CPU spike.
  • $ Shell: This sets up the pipe at the file descriptor level (Kernel Space) before the processes start. The data flows directly from proces…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by adworacz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants