<?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: Launch Reel</title>
    <description>The latest articles on DEV Community by Launch Reel (@launch_reel_317899f6b4387).</description>
    <link>https://dev.to/launch_reel_317899f6b4387</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%2F4252970%2F2f1fd1f4-cd8b-407d-a894-40b5672ae4a6.png</url>
      <title>DEV Community: Launch Reel</title>
      <link>https://dev.to/launch_reel_317899f6b4387</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/launch_reel_317899f6b4387"/>
    <language>en</language>
    <item>
      <title>Two ffmpeg flags that made our in-browser video export 7x slower (and gave us frozen frames)</title>
      <dc:creator>Launch Reel</dc:creator>
      <pubDate>Thu, 19 Nov 2026 04:53:43 +0000</pubDate>
      <link>https://dev.to/launch_reel_317899f6b4387/two-ffmpeg-flags-that-made-our-in-browser-video-export-7x-slower-and-gave-us-frozen-frames-12ca</link>
      <guid>https://dev.to/launch_reel_317899f6b4387/two-ffmpeg-flags-that-made-our-in-browser-video-export-7x-slower-and-gave-us-frozen-frames-12ca</guid>
      <description>&lt;p&gt;We build &lt;a href="https://launchreel.pro" rel="noopener noreferrer"&gt;LaunchReel&lt;/a&gt;, a tool that makes short vertical video ads. The editor exports the final MP4 in the browser with ffmpeg.wasm: trim each clip, concatenate, then burn captions on top. Two small flag choices cost us a lot of debugging. Both are easy to repeat, so here they are.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Pin every video input to one frame rate
&lt;/h2&gt;

&lt;p&gt;Our segments come from different sources: AI-generated clips, user uploads from phones, still images turned into short clips. Their native frame rates differ (24, 25, 30, 29.97, variable).&lt;/p&gt;

&lt;p&gt;If you trim each one with its own rate and then concat, you get &lt;strong&gt;frozen or duplicated frames at the segment boundaries&lt;/strong&gt;, and anything timed against the output (like a caption highlighting the current word) can briefly show the previous state at fast cuts.&lt;/p&gt;

&lt;p&gt;The fix is boring: choose one export rate and force it on every input and output that touches video.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# video segment&lt;/span&gt;
ffmpeg -ss 2.0 -t 3.5 -i clip.mp4 -r 30 -c:v libx264 -pix_fmt yuv420p seg1.mp4

&lt;span class="c"&gt;# still image held as a segment&lt;/span&gt;
ffmpeg -loop 1 -framerate 30 -t 2.0 -i photo.png -r 30 -c:v libx264 -pix_fmt yuv420p seg2.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We keep a test that asserts &lt;code&gt;-r 30&lt;/code&gt; is on every trim command. If it fails, we fix the pipeline, not the assertion.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Don't loop a full-frame overlay image with an input frame rate
&lt;/h2&gt;

&lt;p&gt;Captions are rendered as transparent PNGs the size of the video (1080×1920) and composited with &lt;code&gt;overlay&lt;/code&gt;, about 30 per filtergraph, each enabled only during its time window.&lt;/p&gt;

&lt;p&gt;This version looks harmless:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-loop 1 -framerate 30 -i ovl0.png   &lt;span class="c"&gt;# repeated for each caption&lt;/span&gt;
...
&lt;span class="o"&gt;[&lt;/span&gt;0:v&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;1:v&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nv"&gt;overlay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0:0:enable=&lt;span class="s1"&gt;'between(t,1.2,1.8)'&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;v1&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-loop 1&lt;/code&gt; with an explicit input rate turns each PNG into a 30 fps stream for the whole video length. ffmpeg then decodes and scales a full ~8 MB RGBA frame 30 times a second &lt;strong&gt;per caption input&lt;/strong&gt;. With 30 inputs chained, that's hundreds of full-frame rescales per output frame. On the single-threaded wasm build, a 90-second export went from about 8 minutes to about an hour, with batches running at ~0.05x.&lt;/p&gt;

&lt;p&gt;You won't see it in a small test with one tiny PNG. It needs all four together: input rate, full-frame image, loop, deep chain.&lt;/p&gt;

&lt;p&gt;What works: feed each PNG as &lt;strong&gt;one still frame&lt;/strong&gt; and let &lt;code&gt;overlay&lt;/code&gt; hold it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-framerate 30 -i ovl0.png            &lt;span class="c"&gt;# no -loop, no -t&lt;/span&gt;
...
&lt;span class="o"&gt;[&lt;/span&gt;0:v&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;1:v&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nv"&gt;overlay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0:0:enable=&lt;span class="s1"&gt;'gte(t,1.2)*lt(t,1.8)'&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;v1&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;overlay&lt;/code&gt; keeps the last frame of a finished input by default (&lt;code&gt;eof_action=repeat&lt;/code&gt;), so the single frame stays available for the whole timeline and &lt;code&gt;enable&lt;/code&gt; decides when it's drawn. Two things to avoid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;shortest=1&lt;/code&gt; ends the output when the one-frame input ends.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;eof_action=pass&lt;/code&gt; stops drawing the caption after its first frame, so it never shows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bounding the loop with &lt;code&gt;-t&lt;/code&gt; or &lt;code&gt;-itsoffset&lt;/code&gt; instead also looked tempting. In our case it deadlocked ffmpeg's frame sync whenever the first caption in a batch started well after t=0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One output frame rate, set explicitly everywhere, beats trusting each source.&lt;/li&gt;
&lt;li&gt;A large image input should be one held frame plus &lt;code&gt;enable&lt;/code&gt;, not a looped stream.&lt;/li&gt;
&lt;li&gt;Write tests that assert the flags. These bugs return quietly when someone "cleans up" a command.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're exporting for TikTok, Reels or Shorts, the target is 1080×1920 (9:16), H.264 MP4, with captions burned in because feeds autoplay muted. We keep a free &lt;a href="https://launchreel.pro/tools/video-ad-specs" rel="noopener noreferrer"&gt;short-form video ad specs lookup&lt;/a&gt; with lengths and caption guidance per platform.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I'm the founder of LaunchReel.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ffmpeg</category>
      <category>webassembly</category>
      <category>video</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
