<?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: Monir Uddin</title>
    <description>The latest articles on DEV Community by Monir Uddin (@moniruddin_amaarsoft).</description>
    <link>https://dev.to/moniruddin_amaarsoft</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%2F4257704%2Ff8554884-4a18-4e82-ad79-82e80425f3d2.png</url>
      <title>DEV Community: Monir Uddin</title>
      <link>https://dev.to/moniruddin_amaarsoft</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/moniruddin_amaarsoft"/>
    <language>en</language>
    <item>
      <title>FFmpeg Video Compression: The 5 Settings That Actually Matter</title>
      <dc:creator>Monir Uddin</dc:creator>
      <pubDate>Sat, 21 Nov 2026 17:20:41 +0000</pubDate>
      <link>https://dev.to/moniruddin_amaarsoft/ffmpeg-video-compression-the-5-settings-that-actually-matter-9ho</link>
      <guid>https://dev.to/moniruddin_amaarsoft/ffmpeg-video-compression-the-5-settings-that-actually-matter-9ho</guid>
      <description>&lt;p&gt;Most "how to compress a video" answers tell you to lower the bitrate and hope for the best. That usually gives you a smaller file that looks noticeably worse.&lt;/p&gt;

&lt;p&gt;A better approach is to let the encoder decide how many bits each frame needs. Here are the five settings that make the biggest difference, with copy-paste FFmpeg commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Pick the right codec
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;H.264 (&lt;code&gt;libx264&lt;/code&gt;)&lt;/strong&gt;: plays everywhere, including old phones, browsers and WhatsApp. The safe default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;H.265/HEVC (&lt;code&gt;libx265&lt;/code&gt;)&lt;/strong&gt;: typically 30 to 50 percent smaller at similar quality, but some older devices and browsers cannot play it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AV1 (&lt;code&gt;libsvtav1&lt;/code&gt;)&lt;/strong&gt;: even more efficient, but encoding is slower and support is still uneven.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you do not know where the file will be played, use H.264.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Use constant quality (CRF), not a fixed bitrate
&lt;/h2&gt;

&lt;p&gt;CRF tells the encoder "keep this quality level" and lets the bitrate go up for complex scenes and down for simple ones.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ffmpeg -i input.mp4 -c:v libx264 -crf 22 -preset medium -c:a copy output.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For &lt;code&gt;libx264&lt;/code&gt;, the scale is 0 to 51. Lower means better quality and bigger files.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;18 to 20: visually close to the source&lt;/li&gt;
&lt;li&gt;21 to 24: the sweet spot for most screen recordings and phone videos&lt;/li&gt;
&lt;li&gt;26+: visible softening, fine for previews&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For &lt;code&gt;libx265&lt;/code&gt;, the equivalent values are roughly 4 to 6 higher (start around 26 to 28).&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Choose a preset
&lt;/h2&gt;

&lt;p&gt;The preset trades encoding time for compression efficiency. Slower presets produce smaller files at the same CRF.&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;# faster encode, slightly larger file&lt;/span&gt;
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -preset veryfast output.mp4

&lt;span class="c"&gt;# slower encode, smaller file&lt;/span&gt;
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -preset slow output.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;medium&lt;/code&gt; is a good default. Use &lt;code&gt;veryfast&lt;/code&gt; when you are batch-processing a lot of files and time matters more than a few megabytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Downscale when the viewer does not need the pixels
&lt;/h2&gt;

&lt;p&gt;A 4K screen recording watched on a phone is mostly wasted data. Scaling to 1080p or 720p often has a bigger effect than any other setting.&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;# scale to 1080p height, keep aspect ratio (-2 keeps width even)&lt;/span&gt;
ffmpeg -i input.mp4 -vf &lt;span class="s2"&gt;"scale=-2:1080"&lt;/span&gt; -c:v libx264 -crf 22 -preset medium output.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For tutorials and slide recordings, you can also drop the frame rate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ffmpeg -i input.mp4 -vf &lt;span class="s2"&gt;"scale=-2:1080,fps=30"&lt;/span&gt; -c:v libx264 -crf 22 output.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep the original frame rate for gameplay or sport.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Do not forget the audio
&lt;/h2&gt;

&lt;p&gt;Uncompressed or high-bitrate audio can be a surprising share of a small file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ffmpeg -i input.mp4 -c:v libx264 -crf 22 -preset medium -c:a aac -b:a 128k -movflags +faststart output.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;128 kbps AAC is fine for voice. &lt;code&gt;-movflags +faststart&lt;/code&gt; moves metadata to the start of the file so it begins playing before it is fully downloaded, which helps on the web.&lt;/p&gt;

&lt;h2&gt;
  
  
  A complete "good default" command
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ffmpeg -i input.mp4 \
  -vf &lt;span class="s2"&gt;"scale=-2:1080"&lt;/span&gt; \
  -c:v libx264 -crf 23 -preset medium \
  -c:a aac -b:a 128k \
  -movflags +faststart \
  output.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Two mistakes to avoid
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Re-compressing a compressed file.&lt;/strong&gt; Every encode loses a little quality. Always start from the original.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uploading private videos to online compressors.&lt;/strong&gt; If the recording shows client data, emails or anything internal, compress it locally. FFmpeg and HandBrake both run entirely on your machine.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  If you prefer a GUI
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HandBrake&lt;/strong&gt; is free and open source. Pick a preset, set RF to about 22, done.&lt;/li&gt;
&lt;li&gt;Disclosure: I work on &lt;strong&gt;Amaar Toolkit&lt;/strong&gt;, a Windows app from our small team at Amaar Soft that wraps a video compressor and converter, a screen recorder and a PDF editor into one offline app. It is paid, so HandBrake is the better pick if you only need free. Details: &lt;a href="https://amaarsoft.com/amaar-toolkit.html" rel="noopener noreferrer"&gt;https://amaarsoft.com/amaar-toolkit.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What CRF do you usually use? I would like to hear what works for your type of content.&lt;/p&gt;

</description>
      <category>ffmpeg</category>
      <category>video</category>
      <category>tutorial</category>
      <category>windows</category>
    </item>
  </channel>
</rss>
