<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Get Info: #shell</title>
    <description>Posts tagged “shell” — Blog of independent game and app developer Matt Sephton. Featuring vintage Macintosh, game development, digital artwork, Japanese esoterica, video game reviews, hacks and tips, and much more.</description>
    <link>https://blog.gingerbeardman.com/tag/shell/</link>
    <atom:link href="https://blog.gingerbeardman.com/tag/shell/index.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sun, 28 Jun 2026 16:57:32 +0000</pubDate>
    <lastBuildDate>Sun, 28 Jun 2026 16:57:32 +0000</lastBuildDate>
    <generator>Jekyll v4.4.1</generator>

    
      
        <item>
          <title>Taking command of the Context Menu in macOS</title>
          <description>&lt;p&gt;Yesterday on Twitter the inimitable &lt;a href=&quot;https://twitter.com/mortenjust/status/1817991110544744764&quot;&gt;Morten Just posted a preview of a tool he’s created&lt;/a&gt; that wrap ffmpeg to allow movies, such screen recordings but pretty much anything, to be re-encoded to a smaller filesize.&lt;/p&gt;

&lt;p&gt;I responded with a trick I use to do the same on “right-click” context menu using a macOS app called ContextMenu, and others said it was possible to do it using Automator (with some caveats). In this blog post I’ll compare the two.&lt;/p&gt;

&lt;p&gt;But first… let’s talk about how we will make this work.&lt;/p&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;processing-files-through-shell-scripts&quot;&gt;Processing files through shell scripts&lt;/h1&gt;

&lt;p&gt;We’ll be making use of command line tools to do the heavy lifting, but don’t worry I’ll show that this can be as simple as a single-line command to process a single file, or a shell scripts of a few lines to process multiple files.&lt;/p&gt;

&lt;h3 id=&quot;single-files&quot;&gt;Single files&lt;/h3&gt;

&lt;p&gt;The one-line command to convert a video or audio file can be as simple as the following:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/opt/homebrew/bin/ffmpeg &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@%.*&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.mp4&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There are some assumptions here:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ffmpeg&lt;/code&gt; has been installed using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;brew&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;my Mac is Apple silicon, so &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;brew&lt;/code&gt; installs commands to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/opt/homebrew/bin/&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;(older Intel Macs will have them installed to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/local/bin/&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;the script is called with parameters passed by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;argv&lt;/code&gt; so the file is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$@&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;the new file will have the same name as the original, but with a new .mp4 file extension&lt;/li&gt;
  &lt;li&gt;it only works on single files (read on)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We &lt;em&gt;could&lt;/em&gt; add an extra parameter to the command line to use hardware encoding (hevc_videotoolbox) &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-c:v hevc_videotoolbox&lt;/code&gt;, which would be something like twice as fast, but this will not reduce the file size. So we stick with ffmpeg default settings.&lt;/p&gt;

&lt;p&gt;You can take the exact same approach with any destination format as it is decided by the file extension. Cool. You could convert any of ffmpeg’s supported file types to any other, such as WAV, OGG, MKV, etc.&lt;/p&gt;

&lt;p&gt;And as we’ll see later we can take this simple command and change it to use other command line tools to compress GIFs, with or without upscaling, and many other timesaving tasks. Powerful stuff!&lt;/p&gt;

&lt;h3 id=&quot;multiple-files&quot;&gt;Multiple files&lt;/h3&gt;

&lt;p&gt;To extend this approach for multiple files you can use the following for loop:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;f &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    /opt/homebrew/bin/ffmpeg &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;%.*&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.mp4&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;multiple-files-in-parallel&quot;&gt;Multiple files in parallel&lt;/h3&gt;

&lt;p&gt;And to process those multiple files in parallel (be careful not to overwhelm your computer!) we can background each execution using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;&lt;/code&gt; symbol.&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;f &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    /opt/homebrew/bin/ffmpeg &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;%.*&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.mp4&quot;&lt;/span&gt; &amp;amp;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;automator&quot;&gt;Automator&lt;/h2&gt;

&lt;p&gt;This has been a built-in macOS app since 2005. Setup is relatively straightforward:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create a new &lt;em&gt;Quick Action&lt;/em&gt; workflow&lt;/li&gt;
  &lt;li&gt;Workflow receives current: &lt;em&gt;movie files&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;in: &lt;em&gt;Finder&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Add a new action of type action &lt;em&gt;Run Shell Script&lt;/em&gt; (search for it in the sidebar)&lt;/li&gt;
  &lt;li&gt;Pass input: &lt;em&gt;as arguments&lt;/em&gt; (this will give us a template command)&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Replace the echo line with your command&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Save&lt;/em&gt;, name it “Duplicate as MP4”&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn.gingerbeardman.com/images/posts/take-command-automator-setup.png&quot; alt=&quot;PNG&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The menu item is now available on the context menu, inside the &lt;em&gt;Quick Actions&lt;/em&gt; submenu. After repeated use I find this submenu too annoying, but you may fare better.&lt;/p&gt;

&lt;p class=&quot;tofigure&quot;&gt;&lt;img src=&quot;https://cdn.gingerbeardman.com/images/posts/take-command-automator-finder.png&quot; alt=&quot;PNG&quot; title=&quot;Automator Quick Action in Finder Context Menu&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So, pretty easy! But, there are some caveats or limitations that may, or may not, annoy you. Perhaps we don’t want the menu item to appear for such a broad range of files (all “movie files”), or maybe we want it to appear for multiple types of files (both “audio files” and “movie files”). Sadly this is not so easy with Automator.&lt;/p&gt;

&lt;p&gt;Automator stores these files at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/Library/Services/&lt;/code&gt; and they will migrate to a new Mac.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;contextmenu&quot;&gt;ContextMenu&lt;/h2&gt;

&lt;p&gt;Many years ago I found &lt;a href=&quot;https://apps.apple.com/us/app/context-menu/id1236813619?mt=12&quot;&gt;ContextMenu&lt;/a&gt; ($4.99) which solves all of the issues I have with the Automator approach. There’s also a free version, &lt;a href=&quot;https://apps.apple.com/gb/app/context-menu-lite/id1261373706?mt=12&quot;&gt;ContextMenu Lite&lt;/a&gt;, that supports up to 3 actions to give you a taste of the good stuff.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Submenu is optional&lt;/li&gt;
  &lt;li&gt;Apply to multiple types (files or directories; can be as granular as file extension)&lt;/li&gt;
  &lt;li&gt;Show output (sometimes you want to see the results of the command)&lt;/li&gt;
  &lt;li&gt;Confirmation before running (if it’s a potentially dangerous operation)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn.gingerbeardman.com/images/posts/take-command-context-menu-setup.png&quot; alt=&quot;PNG&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The menu item displays in Finder as follows:&lt;/p&gt;

&lt;p class=&quot;tofigure&quot;&gt;&lt;img src=&quot;https://cdn.gingerbeardman.com/images/posts/take-command-context-menu-finder.png&quot; alt=&quot;PNG&quot; title=&quot;ContextMenu Action in Finder Context Menu&quot; /&gt;&lt;/p&gt;

&lt;p&gt;ContextMenu stores these files in its own group folder, right click an action and choose &lt;em&gt;Show in Finder&lt;/em&gt;, but you can specify your own folder in a location of your choice. Both will migrate to a new Mac, but the later might give you more control.&lt;/p&gt;

&lt;p&gt;Edit: we can limit actions to running on files with specific extensions or, since update 1.4.4 &lt;a href=&quot;https://gist.github.com/RhetTbull/7221ef3cfd9d746f34b2550d4419a8c2&quot;&gt;specific UTI types&lt;/a&gt;.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;compressing-a-gif&quot;&gt;Compressing a GIF&lt;/h2&gt;

&lt;p&gt;We can use the &lt;a href=&quot;https://www.lcdf.org/gifsicle/&quot;&gt;gifsicle&lt;/a&gt; command line tool to optimise (compress) an Animated GIF. The a parameters I use here are explained in the &lt;a href=&quot;https://www.lcdf.org/gifsicle/man.html&quot;&gt;gifsicle man page&lt;/a&gt;, and I arrived at them with &lt;a href=&quot;/2016/06/16/post-processing-animated-gifs/&quot;&gt;years of experimentation&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/opt/homebrew/bin/gifsicle &lt;span class=&quot;nt&quot;&gt;-O1&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-Okeep-empty&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--careful&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@%.gif&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.o.gif&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can also do the same thing whilst scaling it up by a factor of 2:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/opt/homebrew/bin/gifsicle &lt;span class=&quot;nt&quot;&gt;-O1&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-Okeep-empty&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--careful&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--scale&lt;/span&gt; 2 &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@%.gif&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.o.gif&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;repository-of-contextmenu-actions&quot;&gt;Repository of ContextMenu Actions&lt;/h2&gt;

&lt;p&gt;Here’s my repo of shared actions. Inside each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cmaction&lt;/code&gt; file is a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.sh&lt;/code&gt; file which contains the command that you can use in Automator if you’d like.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/gingerbeardman/contextmenu-actions&quot;&gt;github.com/gingerbeardman/contextmenu-actions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These include many useful commands such as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Convert BIN+CUE to ISO&lt;/li&gt;
  &lt;li&gt;Change sample rate of audio&lt;/li&gt;
  &lt;li&gt;Convert image to 1-bit&lt;/li&gt;
  &lt;li&gt;Convert image format&lt;/li&gt;
  &lt;li&gt;Create Clean ZIP&lt;/li&gt;
  &lt;li&gt;Duplicate audio as alternative format&lt;/li&gt;
  &lt;li&gt;Duplicate image as alternative format&lt;/li&gt;
  &lt;li&gt;Duplicate movie as alternative format&lt;/li&gt;
  &lt;li&gt;File information&lt;/li&gt;
  &lt;li&gt;Generate images for web&lt;/li&gt;
  &lt;li&gt;Make script executable&lt;/li&gt;
  &lt;li&gt;Move file (includes helper app)&lt;/li&gt;
  &lt;li&gt;New file with clipboard&lt;/li&gt;
  &lt;li&gt;Open file with specific apps&lt;/li&gt;
  &lt;li&gt;Optimize GIF&lt;/li&gt;
  &lt;li&gt;Set GIF to loop infinitely&lt;/li&gt;
  &lt;li&gt;Show GIF info&lt;/li&gt;
  &lt;li&gt;Playdate Colorize IMG&lt;/li&gt;
  &lt;li&gt;Replace Existing App (warning)&lt;/li&gt;
  &lt;li&gt;Scale image to certain percentage&lt;/li&gt;
  &lt;li&gt;Set as MacJapanese encoding&lt;/li&gt;
  &lt;li&gt;Show hashes (includes helper app)&lt;/li&gt;
  &lt;li&gt;Stub out file (warning)&lt;/li&gt;
  &lt;li&gt;Touch file&lt;/li&gt;
&lt;/ul&gt;
</description>
          <author>by Matt Sephton</author>
          <pubDate>Tue, 30 Jul 2024 16:14:00 +0000</pubDate>
          <link>https://blog.gingerbeardman.com/2024/07/30/taking-command-of-the-context-menu-in-macos/</link>
          <guid isPermaLink="true">https://blog.gingerbeardman.com/2024/07/30/taking-command-of-the-context-menu-in-macos/</guid>
        </item>
      
    
      
        <item>
          <title>Post-processing Animated GIFs</title>
          <description>&lt;blockquote&gt;
  &lt;p&gt;This article was originally posted on &lt;a href=&quot;https://www.lexaloffle.com/bbs/?tid=3614&quot;&gt;pico8 BBS in 2016&lt;/a&gt;, and on &lt;a href=&quot;https://devforum.play.date/t/post-processing-animated-gifs/1074&quot;&gt;Playdate devforum in 2020&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I was interested to see how easy/difficult it is to edit the animated GIF recordings. My goal was to trim some frames from the beginning and end to make a more succinct video.&lt;/p&gt;

&lt;p&gt;After much trial, error and experimentation here are my findings using Mac OS X.&lt;/p&gt;

&lt;p&gt;The game shown in the GIFs is &lt;a href=&quot;https://www.lexaloffle.com/bbs/?tid=3547&quot;&gt;Worm Nom Nom by ilkkke &amp;amp; kometbomb&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;p&gt;Animated GIFs can be:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;viewed frame-by-frame using system Preview.app&lt;/li&gt;
  &lt;li&gt;manipulated using “gifsicle”, “imagemagick”, “graphicsmagick” command line tools&lt;/li&gt;
  &lt;li&gt;converted using “ffmpeg” command line tool&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notes&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;useful tools need to be installed, you may wish to use the “brew” command line tool or similar.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;viewing&quot;&gt;Viewing&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Open the GIF in Preview.app and it will show you all frames.&lt;/li&gt;
  &lt;li&gt;Preview calls the first frame 1 (one), but other tools usually call it 0 (zero).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;original/source animated GIF:
&lt;img src=&quot;https://cdn.gingerbeardman.com/images/posts/post-processing-animated-gifs-01.gif&quot; alt=&quot;GIF&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;un-optimising&quot;&gt;Un-Optimising&lt;/h2&gt;

&lt;p&gt;Warning: If you have previously optimised your GIF to reduce filesize, &lt;a href=&quot;https://devforum.play.date/t/optimising-gifs-from-mb-to-kb/788&quot;&gt;as in this other thread&lt;/a&gt;, and you want to edit the GIF further then be sure to first use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gifsicle -U&lt;/code&gt; to unoptimise it, otherwise the editing commands won’t work as expected.&lt;/p&gt;

&lt;h2 id=&quot;trimming&quot;&gt;Trimming&lt;/h2&gt;

&lt;p&gt;required: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gifsicle&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;then this is how you trim&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gifsicle anim.gif &lt;span class=&quot;s2&quot;&gt;&quot;#212-238&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; trimmed.gif
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;note: this makes a copy of the GIF and keep frames 213 to 239 (gifsicle uses zero based frame count)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn.gingerbeardman.com/images/posts/post-processing-animated-gifs-02.gif&quot; alt=&quot;GIF&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;resizing&quot;&gt;Resizing&lt;/h2&gt;

&lt;p&gt;if you want to double size of the image:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gifsicle &lt;span class=&quot;nt&quot;&gt;--scale&lt;/span&gt; 2 trimmed.gif &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; resized.gif
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn.gingerbeardman.com/images/posts/post-processing-animated-gifs-03.gif&quot; alt=&quot;GIF&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;captioning&quot;&gt;Captioning&lt;/h2&gt;

&lt;p&gt;if you want to add an overlay to caption the animation&lt;/p&gt;

&lt;p&gt;required: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;imagemagick&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;graphicsmagick&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;then use this bash script:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;caption&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$2&lt;/span&gt;
: &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Usage: &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; anim.gif overlay.gif [output.gif]&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
: &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Usage: &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; anim.gif overlay.gif [output.gif]&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;fnsource&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;basename&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$source&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; .gif&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;fncaption&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;basename&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$caption&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; .gif&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:-&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fnsource&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fncaption&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.gif&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;

gifsicle &lt;span class=&quot;nt&quot;&gt;-E&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$source&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;f &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.gif.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;composite &lt;span class=&quot;nv&quot;&gt;$caption&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done
&lt;/span&gt;gifsicle &lt;span class=&quot;nt&quot;&gt;--loopcount&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.gif.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$output&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.gif.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;how to run the command&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./caption.sh anim.gif overlay.gif &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;output.gif]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;note: if you do not specify an output name, it will be named using original filenames, eg. anim-overlay.gif&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/posts/post-processing-animated-gifs-04.gif&quot;&gt;overlay.gif&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn.gingerbeardman.com/images/posts/post-processing-animated-gifs-05.gif&quot; alt=&quot;GIF&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;converting-to-video-for-youtube&quot;&gt;Converting to Video for YouTube&lt;/h2&gt;

&lt;p&gt;required: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ffmpeg&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;to convert the GIF to MP4:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ffmpeg &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; trimmed.gif &lt;span class=&quot;nt&quot;&gt;-movflags&lt;/span&gt; faststart &lt;span class=&quot;nt&quot;&gt;-pix_fmt&lt;/span&gt; yuv420p video.mp4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;video uploaded to YouTube:&lt;/p&gt;

&lt;lite-youtube style=&quot;aspect-ratio: 1/1;&quot; videoid=&quot;Ydeg4bNHn08&quot; params=&quot;start=0&amp;amp;modestbranding=2&quot;&gt;
&lt;/lite-youtube&gt;

</description>
          <author>by Matt Sephton</author>
          <pubDate>Thu, 16 Jun 2016 00:00:00 +0000</pubDate>
          <link>https://blog.gingerbeardman.com/2016/06/16/post-processing-animated-gifs/</link>
          <guid isPermaLink="true">https://blog.gingerbeardman.com/2016/06/16/post-processing-animated-gifs/</guid>
        </item>
      
    

  </channel>
</rss>
