<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kenji</title>
    <description>The latest articles on DEV Community by Kenji (@kenjiginjo).</description>
    <link>https://dev.to/kenjiginjo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1069530%2F2c786d50-bf19-4487-be88-7bbe5fbc5802.png</url>
      <title>DEV Community: Kenji</title>
      <link>https://dev.to/kenjiginjo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kenjiginjo"/>
    <language>en</language>
    <item>
      <title>I needed audio in Bun, so I skipped fluent-ffmpeg</title>
      <dc:creator>Kenji</dc:creator>
      <pubDate>Wed, 09 Sep 2026 12:34:18 +0000</pubDate>
      <link>https://dev.to/kenjiginjo/i-needed-audio-in-bun-so-i-skipped-fluent-ffmpeg-5g83</link>
      <guid>https://dev.to/kenjiginjo/i-needed-audio-in-bun-so-i-skipped-fluent-ffmpeg-5g83</guid>
      <description>&lt;p&gt;Bun's Node compatibility layer will run &lt;code&gt;fluent-ffmpeg&lt;/code&gt;. That is the honest answer, and for a lot of apps it is good enough.&lt;/p&gt;

&lt;p&gt;I still ended up writing a tiny wrapper around &lt;code&gt;Bun.spawn&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The jobs I actually had were boring: transcode a file, pipe a stream, turn whatever the user uploaded into 16 kHz mono PCM for Whisper. &lt;code&gt;fluent-ffmpeg&lt;/code&gt; can do all of that, plus video, filters, and a fluent builder I was not going to use. In a Bun-only service I also did not want "it works through the Node compat layer" as the whole story.&lt;/p&gt;

&lt;p&gt;So &lt;a href="https://github.com/KenjiGinjo/bun-ffmpeg" rel="noopener noreferrer"&gt;bun-ffmpeg&lt;/a&gt; is intentionally small. Audio only. System &lt;code&gt;ffmpeg&lt;/code&gt; / &lt;code&gt;ffprobe&lt;/code&gt;. Typed helpers. No bundled binary.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like
&lt;/h2&gt;

&lt;p&gt;Install ffmpeg yourself (&lt;code&gt;brew install ffmpeg&lt;/code&gt;, &lt;code&gt;apt install ffmpeg&lt;/code&gt;, or set &lt;code&gt;FFMPEG_PATH&lt;/code&gt; in Docker). Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bun add bun-ffmpeg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;audio&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bun-ffmpeg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;audio&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;input.mp3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;output.aac&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;codec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aac&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;bitrate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;192k&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;channels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;sampleRate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;44100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Whisper path is one function. It always emits 16 kHz, mono, &lt;code&gt;pcm_s16le&lt;/code&gt; WAV:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;audioWav&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bun-ffmpeg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;wav&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;audioWav&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Uint8Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Bun&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;input.mp3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;arrayBuffer&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Bun&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;input.16k.wav&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;wav&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Streams work the same way: &lt;code&gt;ReadableStream&lt;/code&gt; in, file or chunk callbacks out. If the binary is missing you get an error that tells you to install ffmpeg instead of a raw &lt;code&gt;ENOENT&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not fluent-ffmpeg
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Need&lt;/th&gt;
&lt;th&gt;fluent-ffmpeg&lt;/th&gt;
&lt;th&gt;bun-ffmpeg&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Runtime&lt;/td&gt;
&lt;td&gt;Node, works on Bun via compat&lt;/td&gt;
&lt;td&gt;Bun only (&lt;code&gt;Bun.spawn&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Surface&lt;/td&gt;
&lt;td&gt;Video, filters, graphs&lt;/td&gt;
&lt;td&gt;Audio&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Binary&lt;/td&gt;
&lt;td&gt;Still needs ffmpeg on the machine&lt;/td&gt;
&lt;td&gt;Same&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shape&lt;/td&gt;
&lt;td&gt;Fluent builder&lt;/td&gt;
&lt;td&gt;A handful of functions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you are muxing video or building filter graphs, keep fluent-ffmpeg. This package is for the case where the runtime is Bun and the media is audio.&lt;/p&gt;

&lt;p&gt;Under the hood there is no magic: spawn &lt;code&gt;ffmpeg&lt;/code&gt;, pass &lt;code&gt;-i&lt;/code&gt;, codec, bitrate, channels, sample rate, and either a path or &lt;code&gt;pipe:0&lt;/code&gt; / &lt;code&gt;pipe:1&lt;/code&gt;. The wrapper exists so you do not re-derive those flags in every script.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it will not do
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;Video&lt;/li&gt;
&lt;li&gt;A fluent API&lt;/li&gt;
&lt;li&gt;Shipping ffmpeg inside the npm tarball&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;v0.3.0 added &lt;code&gt;FFMPEG_PATH&lt;/code&gt; / &lt;code&gt;FFPROBE_PATH&lt;/code&gt; for containers, and &lt;code&gt;FfmpegNotFoundError&lt;/code&gt; when the binary is not there.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/KenjiGinjo/bun-ffmpeg" rel="noopener noreferrer"&gt;github.com/KenjiGinjo/bun-ffmpeg&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;npm: &lt;code&gt;bun add bun-ffmpeg&lt;/code&gt;&lt;/p&gt;

</description>
      <category>bunjs</category>
      <category>ffmpeg</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
