<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>optimization on S Anand</title>
    <link>https://www.s-anand.net/blog/tag/optimization/</link>
    <description>Recent content in optimization on S Anand</description>
    <generator>Hugo -- 0.156.0</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 28 Feb 2026 09:18:56 +0800</lastBuildDate>
    <atom:link href="https://www.s-anand.net/blog/tag/optimization/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>AI video compression</title>
      <link>https://www.s-anand.net/blog/ai-video-compression/</link>
      <pubDate>Sat, 28 Feb 2026 09:18:56 +0800</pubDate>
      <guid>https://www.s-anand.net/blog/ai-video-compression/</guid>
      <description>&lt;p&gt;I recorded a short screen cast of a demo I built. It was ~900KB - way too large to publish as a thumbnail. So I asked ChatGPT:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What&amp;rsquo;s the best equivalent of squoosh.app for WEBM compression? I&amp;rsquo;m looking for a free modern high-quality online video compressor.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There are a few, and they compressed it to a third of its size, but 300KB is still too large. So I attached the original and asked:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I am compressing screenshots like this. They&amp;rsquo;re often not large. I don&amp;rsquo;t mind cropping the edges by a few pixels to make it a multiple 2, 4, or 8 if that&amp;rsquo;ll help. I certainly am OK with a lower frame rate. I&amp;rsquo;d like an image quality that a human eye can just SLIGHTLY detect as worse than the original, but only VERY SLIGHTLY.&lt;/p&gt;
&lt;p&gt;What&amp;rsquo;s the best way of using ffmpeg or similar tools to compress such a file?&lt;/p&gt;
&lt;p&gt;Think like an expert:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What would an expert in this field check that beginners would miss?&lt;/li&gt;
&lt;li&gt;What patterns would an expert in this field recognize that beginners would miss?&lt;/li&gt;
&lt;li&gt;In this context, what questions would an expert ask that a beginner would not know to?&lt;/li&gt;
&lt;li&gt;If this goes wrong, what are the most likely reasons?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;hellip; and list the best (diverse, testing different hypotheses) compression command options.&lt;/p&gt;
&lt;p&gt;Run them on this video and let me download the resulting videos for visual comparison. Interview me. Give me a list of questions that I can easily answer by looking at the videos and I&amp;rsquo;ll share those with you to help you decide the best compression command for me.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This leverages 3 tricks.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;These are online coding agents. So they can write &lt;em&gt;and&lt;/em&gt; run code.&lt;/li&gt;
&lt;li&gt;The &amp;ldquo;Think like an expert&amp;rdquo; prompt is my new &amp;ldquo;Think step by step&amp;rdquo; prompt and works quite well.&lt;/li&gt;
&lt;li&gt;The &amp;ldquo;Interview me&amp;rdquo; prompt is another powerful one that helps me apply preferences &amp;ndash; and &lt;a href=&#34;https://www.s-anand.net/blog/how-to-develop-taste/&#34;&gt;develop taste&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href=&#34;https://claude.ai/share/73d1caae-4e4e-4c1b-8984-44ac3e86f7cf&#34;&gt;Claude&lt;/a&gt; did a good job of showing different versions and compressing it, but as expected, &lt;a href=&#34;https://chatgpt.com/share/69a24385-87b8-8003-8f41-cb3757a62d13&#34;&gt;ChatGPT&lt;/a&gt; was the obsessive perfectionist. It gave me a huge set of variations of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Files sizes&lt;/li&gt;
&lt;li&gt;Compression formats (VP9: more compatible vs AV1: better compression)&lt;/li&gt;
&lt;li&gt;Quality settings (CRF)&lt;/li&gt;
&lt;li&gt;Frame rates (FPS)&lt;/li&gt;
&lt;li&gt;Color formats (YUV420p vs YUV444p)&lt;/li&gt;
&lt;li&gt;Compression effort (presets)&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;hellip; and asked me to compare between them, like these:&lt;/p&gt;
&lt;div style=&#34;display:flex; gap:12px; flex-wrap:nowrap; align-items:flex-start;&#34;&gt;
  &lt;figure style=&#34;margin:0; text-align:center;&#34;&gt;
    &lt;video src=&#34;https://files.s-anand.net/images/2026-02-28-sql-screencast-crf45-fps15.webm&#34; autoplay loop muted playsinline preload=&#34;metadata&#34; width=&#34;230&#34;&gt;&lt;/video&gt;
    &lt;figcaption&gt;crf: 45 fps: 15 (93K)&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;figure style=&#34;margin:0; text-align:center;&#34;&gt;
    &lt;video src=&#34;https://files.s-anand.net/images/2026-02-28-sql-screencast-crf50-fps15.webm&#34; autoplay loop muted playsinline preload=&#34;metadata&#34; width=&#34;230&#34;&gt;&lt;/video&gt;
    &lt;figcaption&gt;crf: 50 fps: 15 (69K)&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;figure style=&#34;margin:0; text-align:center;&#34;&gt;
    &lt;video src=&#34;https://files.s-anand.net/images/2026-02-28-sql-screencast-crf55-fps5.webm&#34; autoplay loop muted playsinline preload=&#34;metadata&#34; width=&#34;230&#34;&gt;&lt;/video&gt;
    &lt;figcaption&gt;crf: 55 fps: 5 (23K)&lt;/figcaption&gt;
  &lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;The final result is this script:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ffmpeg -hide_banner -stats -v warning -i &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$input&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  -vf &lt;span class=&#34;s2&#34;&gt;&amp;#34;crop=iw-mod(iw\,2):ih-mod(ih\,2),fps=&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$fps&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  -c:v libsvtav1 -preset &lt;span class=&#34;m&#34;&gt;8&lt;/span&gt; -crf &lt;span class=&#34;nv&#34;&gt;$crf&lt;/span&gt; -pix_fmt yuv420p &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  -an &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$output&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&amp;hellip; which does the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Crops the video to a multiple of 2 (which is required for some compression formats)&lt;/li&gt;
&lt;li&gt;Sets the frame rate to a lower value (which reduces file size)&lt;/li&gt;
&lt;li&gt;Uses the AV1 codec (which has better compression than VP9)&lt;/li&gt;
&lt;li&gt;Sets the CRF (Constant Rate Factor) to a value that balances quality and file size&lt;/li&gt;
&lt;li&gt;Sets the pixel format to YUV420p (which is more compatible with players)&lt;/li&gt;
&lt;li&gt;Disables audio (which is not needed for a screencast)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I realized that for the resolution I&amp;rsquo;ll likely see this at, very low frame rates (5 fps) and poor compressions (CRF 55) are good enough.&lt;/p&gt;
&lt;p&gt;My original video was 912KB. The smallest video that looks good enough for me is 23 KB. That&amp;rsquo;s almost a &lt;strong&gt;40x compression&lt;/strong&gt; - small enough to &lt;a href=&#34;https://sanand0.github.io/datastories/sql-migration/&#34;&gt;publish in my data story&lt;/a&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Things I&amp;rsquo;m taking away:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use AI to discover the best configurations for your tool&lt;/li&gt;
&lt;li&gt;Interview yourself to apply preferences and develop taste&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    <item>
      <title>Villager trading is the fastest way to Fortune III</title>
      <link>https://www.s-anand.net/blog/villager-trading-is-the-fastest-way-to-fortune-iii/</link>
      <pubDate>Mon, 28 Oct 2024 01:54:25 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/villager-trading-is-the-fastest-way-to-fortune-iii/</guid>
      <description>&lt;p&gt;&lt;img alt=&#34;Villager trading is the fastest way to Fortune III&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/calvin-minecraft-fortune-3.webp&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://chatgpt.com/share/671e50d9-212c-800c-9580-cdcd57bd616d&#34;&gt;I asked o1-preview&lt;/a&gt; what the fastest way to get to a &lt;a href=&#34;https://minecraft.fandom.com/wiki/Fortune&#34;&gt;Fortune III enchantment&lt;/a&gt; was. My options were:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Using a &lt;a href=&#34;https://minecraft.fandom.com/wiki/Fishing_Rod&#34;&gt;Fishing Rod&lt;/a&gt; with &lt;a href=&#34;https://minecraft.fandom.com/wiki/Luck_of_the_Sea&#34;&gt;Luck of the Sea&lt;/a&gt; III + &lt;a href=&#34;https://minecraft.fandom.com/wiki/Lure&#34;&gt;Lure&lt;/a&gt; 3 and repeatedly fishing.&lt;/li&gt;
&lt;li&gt;Using an &lt;a href=&#34;https://minecraft.fandom.com/wiki/Enchanting_Table&#34;&gt;Enchanting Table&lt;/a&gt; repeatedly until I get Fortune 3. Factor in the time that it would take to get the experience for these experiments&lt;/li&gt;
&lt;li&gt;Making a &lt;a href=&#34;https://minecraft.fandom.com/wiki/Villager&#34;&gt;Villager&lt;/a&gt; a Librarian and breaking their &lt;a href=&#34;https://minecraft.fandom.com/wiki/Lectern&#34;&gt;Lectern&lt;/a&gt; and setting it up again&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In short:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Fishing would take ~30 hours IRL&lt;/li&gt;
&lt;li&gt;Enchanting Table would take ~1 hour IRL, even with efficient XP gaining methods&lt;/li&gt;
&lt;li&gt;Villager trading would take ~18 minutes IRL&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;No contest.&lt;/p&gt;
&lt;p&gt;Looks like my intuition was right about this.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Top 10 Windows XP tips of all time</title>
      <link>https://www.s-anand.net/blog/top-10-windows-xp-tips-of-all-time/</link>
      <pubDate>Sun, 23 Apr 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/top-10-windows-xp-tips-of-all-time/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.techweb.com/wire/software/186500837&#34;&gt;Top 10 Windows XP tips of all time&lt;/a&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ashwin&lt;/strong&gt; &lt;em&gt;3 Sep 2006 10:43 pm&lt;/em&gt;:
hey&amp;hellip;.nice set of links u have here&amp;hellip;btw&amp;hellip;the xp link is down i think&amp;hellip;and i&amp;rsquo;m gonna try the torrents thing&amp;hellip; the calvin search is awesome except for the fact that u can&amp;rsquo;t read the stip immediately&amp;hellip;.but its real good&amp;hellip;.thanks&amp;hellip;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;4 Sep 2006 6:59 am&lt;/em&gt;:
Thanks, Ashwin! I&amp;rsquo;ve fixed the Windows XP tips link.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Faster XP</title>
      <link>https://www.s-anand.net/blog/faster-xp/</link>
      <pubDate>Fri, 03 Feb 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/faster-xp/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.activehowto.com/how-to/4/11/414.htm&#34;&gt;How to make XP run faster&lt;/a&gt;. Advice ranges from the very practical to the very advanced.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Sai&lt;/strong&gt; &lt;em&gt;4 Feb 2006 6:29 pm&lt;/em&gt;:
First impressions, i like the old look better. Maybe it&amp;rsquo;s just because i&amp;rsquo;m used to it!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Anonymous&lt;/strong&gt; &lt;em&gt;4 Feb 2006 11:46 pm&lt;/em&gt;:
looks cool!; feels like a windows next version&amp;hellip;looks like a win 98 &amp;ndash;&amp;gt; win xp makeover&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Chitra&lt;/strong&gt; &lt;em&gt;6 Feb 2006 4:19 am&lt;/em&gt;:
Hey Anand&amp;hellip;good post.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Jagjit&lt;/strong&gt; &lt;em&gt;31 Oct 2006 10:46 am&lt;/em&gt;:
good post Chitra :)&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Designing a better keyboard</title>
      <link>https://www.s-anand.net/blog/designing-a-better-keyboard/</link>
      <pubDate>Mon, 08 Jul 2002 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/designing-a-better-keyboard/</guid>
      <description>&lt;p&gt;An intruiging experiment on &lt;a href=&#34;http://www.visi.com/~pmk/evolved.html&#34;&gt;designing a better keyboard&lt;/a&gt; using a computer.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>256 byte page</title>
      <link>https://www.s-anand.net/blog/256-byte-page/</link>
      <pubDate>Sat, 02 Mar 2002 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/256-byte-page/</guid>
      <description>&lt;p&gt;How good can a 256 byte webpage be? See the &lt;a href=&#34;http://wildmag.de/compo.php&#34;&gt;256b.htm&lt;/a&gt; competition. I was particularly impressed by Bonz-Mandelbrot, Poi-Metaballs and Mados-Divo. &lt;a href=&#34;http://www.256b.com/&#34;&gt;256b.com&lt;/a&gt; has more 256-byte stuff.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Scantips</title>
      <link>https://www.s-anand.net/blog/scantips/</link>
      <pubDate>Wed, 13 Feb 2002 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/scantips/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.scantips.com/&#34;&gt;Scantips&lt;/a&gt;. Ways to improve your scanning.&lt;/p&gt;
</description>
    </item>
  </channel>
</rss>
