{"id":2624,"date":"2026-02-08T16:29:03","date_gmt":"2026-02-08T20:29:03","guid":{"rendered":"https:\/\/lowtek.ca\/roo\/?p=2624"},"modified":"2026-02-08T16:29:03","modified_gmt":"2026-02-08T20:29:03","slug":"re-encoding-transcoding-video-for-space-savings","status":"publish","type":"post","link":"https:\/\/lowtek.ca\/roo\/2026\/re-encoding-transcoding-video-for-space-savings\/","title":{"rendered":"Re-encoding\/transcoding video for space savings"},"content":{"rendered":"<p>There are lots of good reasons to run a <a href=\"https:\/\/jellyfin.org\/\">media server<\/a> at home to host your own content. There are also plenty of legitimate ways to get content, but also many that are less so. I think it is important to pay creators for their efforts, I also really like &#8220;<a href=\"https:\/\/cynmackley.com\/2025\/06\/07\/%F0%9F%92%BF%F0%9F%93%9A%F0%9F%8E%B5-do-you-really-own-your-digital-media\/\">owning<\/a>&#8221; the media I enjoy and not paying repeatedly to re-watch things.<\/p>\n<p>Sometimes you&#8217;ll end up with a version of the content (say captured <a href=\"https:\/\/en.wikipedia.org\/wiki\/Terrestrial_television\">OTA<\/a>) that is both high quality, but huge. An hour long 1080p HDTV capture from my <a href=\"https:\/\/www.silicondust.com\/hdhomerun\/\">HD Homerun<\/a> lands in around 7.7GB. A more efficient encoding can significantly drop that, of course these are <a href=\"https:\/\/en.wikipedia.org\/wiki\/Lossy_compression\">lossy<\/a> encodings meaning that the quality can be less. The trick is to figure out how to pick an encoding of the video that retains most of the quality, but is significantly smaller.<\/p>\n<p>Different <a href=\"https:\/\/en.wikipedia.org\/wiki\/Codec\">codecs<\/a> have different approaches, all with trade-offs, but sometimes it&#8217;s really hard to see the differences. Many of the content creators are also faced with the same dilemma, they have high bit-rate master copies of the content and need to squeeze it down to fit on a DVD or Blu-ray.<\/p>\n<p>Let&#8217;s dive into how we do this. For this example we&#8217;ll take a 45min TV show that starts at 1.9G. It is encoded in AVC1\/H.264 at 6000 kb\/s. The image quality is very good, but it&#8217;s also sort of big and maybe you don&#8217;t care that much about this particular TV series but you do want to retain a copy.<\/p>\n<p><a href=\"https:\/\/ffmpeg.org\/about.html\">FFmpeg<\/a> can fix this for us. We&#8217;ll be moving to H.265 as an encoding, burning a bunch of CPU cycles to get there, and ideally get a video that is substantially the same but uses less storage.<\/p>\n<pre class=\"lang:default decode:true\">$ ffmpeg -i original.mp4 -c:v libx265 \\\r\n  -vtag hvc1 -crf 20 -preset fast \\\r\n  -c:a copy smaller.mp4\r\n<\/pre>\n<p>You can see we&#8217;ve told it to re-encode to the H.265 codec, but to simply copy the audio. The <code>crf<\/code> flag is important for maintaining quality, lower values will be more quality, higher less. If you don&#8217;t supply the flag, a default of 28 is used resulting in more space savings, but to my eyes a softness in the output.<\/p>\n<pre class=\"lang:default decode:true \">Original  2033893144 (1.9G)\r\nSmaller    560561334 (535M)<\/pre>\n<p>That is a significant space savings, the new file is only 27% of the original &#8211; 3 times smaller! Sure, it&#8217;s small, but is it any good?<\/p>\n<p>Let&#8217;s look at some stats. While we have maintained the 1920&#215;1080 resolution, we&#8217;ve dropped the bitrate to 1510 kb\/s. This explains a lot of the saving, we&#8217;ve reduce the number of bits used to create each frame of the image.<\/p>\n<p>We will use ffmpeg to extract a few frames of the two videos for comparison. The use of the .png format will give us &#8220;lossless&#8221; images (but recall the video itself has been encoded in a lossy format).<\/p>\n<pre class=\"lang:default decode:true\">$ ffmpeg -ss 00:04:10 -i original.mp4 -update true -frames:v 1 original-1.png\r\n$ ffmpeg -ss 00:22:08 -i original.mp4 -update true -frames:v 1 original-2.png\r\n\r\n$ ffmpeg -ss 00:04:10 -i smaller.mp4 -update true -frames:v 1 smaller-1.png\r\n$ ffmpeg -ss 00:22:08 -i smaller.mp4 -update true -frames:v 1 smaller-2.png\r\n<\/pre>\n<p><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2625 size-medium aligncenter\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-1-500x281.png\" alt=\"\" width=\"500\" height=\"281\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-1-500x281.png 500w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-1-1024x576.png 1024w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-1-768x432.png 768w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-1-1536x864.png 1536w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-1-1200x675.png 1200w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-1.png 1920w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2627 size-medium aligncenter\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-1-500x281.png\" alt=\"\" width=\"500\" height=\"281\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-1-500x281.png 500w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-1-1024x576.png 1024w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-1-768x432.png 768w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-1-1536x864.png 1536w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-1-1200x675.png 1200w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-1.png 1920w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><\/p>\n<p>Above are the the frames from 4:10, the first\/top is from the original, and the second\/bottom is from the smaller version. You can click through to view the original 1920&#215;1080 image. Visually they seem identical.<\/p>\n<p>Using the <a href=\"https:\/\/openimageio.readthedocs.io\/en\/latest\/idiff.html\">idiff tool<\/a> we can create a difference image and get data about how different these two images are from each other.<\/p>\n<pre class=\"lang:default decode:true \">$ idiff -o diff-1.png original-1.png smaller-1.png \r\nComparing \"original-1.png\" and \"smaller-1.png\"\r\n  Mean error = 0.00534948\r\n  RMS error = 0.00772274\r\n  Peak SNR = 42.2446\r\n  Max error  = 0.145098 @ (834, 553, R)  values are 0.19215688, 0.1764706, 0.15294118 vs 0.3372549, 0.29411766, 0.26666668\r\n  1614504 pixels (77.9%) over 1e-06\r\n  1614504 pixels (77.9%) over 1e-06\r\nFAILURE\r\n<\/pre>\n<p>Ok, so they are different but we knew that. What does the difference image look like?<\/p>\n<p><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-2631 aligncenter\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1-500x281.png\" alt=\"\" width=\"500\" height=\"281\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1-500x281.png 500w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1-1024x576.png 1024w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1-768x432.png 768w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1-1536x864.png 1536w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1-1200x675.png 1200w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1.png 1920w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><\/p>\n<p>Yup, just a big black box not a lot of obvious differences, this agrees with what we we can see ourselves. Let&#8217;s tweak the idiff command to highlight the differences by a scale of 20<\/p>\n<pre class=\"lang:default decode:true \">$ idiff -scale 20 -o diff-1X.png original-1.png smaller-1.png \r\nComparing \"original-1.png\" and \"smaller-1.png\"\r\n  Mean error = 0.00534948\r\n  RMS error = 0.00772274\r\n  Peak SNR = 42.2446\r\n  Max error  = 0.145098 @ (834, 553, R)  values are 0.19215688, 0.1764706, 0.15294118 vs 0.3372549, 0.29411766, 0.26666668\r\n  1614504 pixels (77.9%) over 1e-06\r\n  1614504 pixels (77.9%) over 1e-06\r\nFAILURE\r\n<\/pre>\n<p><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1X.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2632 size-medium\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1X-500x281.png\" alt=\"\" width=\"500\" height=\"281\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1X-500x281.png 500w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1X-1024x576.png 1024w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1X-768x432.png 768w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1X-1536x864.png 1536w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1X-1200x675.png 1200w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-1X.png 1920w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a>Now we can see the small differences magnified, and it&#8217;s in areas you&#8217;d expect, around the edges of objects and in the small details.<\/p>\n<p>Let&#8217;s look at another frame using the same approach.<\/p>\n<p><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2626\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-2-500x281.png\" alt=\"\" width=\"500\" height=\"281\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-2-500x281.png 500w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-2-1024x576.png 1024w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-2-768x432.png 768w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-2-1536x864.png 1536w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-2-1200x675.png 1200w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/original-2.png 1920w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2628\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-2-500x281.png\" alt=\"\" width=\"500\" height=\"281\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-2-500x281.png 500w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-2-1024x576.png 1024w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-2-768x432.png 768w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-2-1536x864.png 1536w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-2-1200x675.png 1200w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/smaller-2.png 1920w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a>Again, the original is the first, and the smaller is the second. Let&#8217;s do the diff, but only grab the scaled version.<\/p>\n<pre class=\"lang:default decode:true \">$ idiff -scale 20 -o diff-2X.png original-2.png smaller-2.png \r\nComparing \"original-2.png\" and \"smaller-2.png\"\r\n  Mean error = 0.00534642\r\n  RMS error = 0.00788875\r\n  Peak SNR = 42.0598\r\n  Max error  = 0.105882 @ (704, 188, B)  values are 0.34117648, 0.3254902, 0.24313727 vs 0.43921572, 0.42352945, 0.34901962\r\n  1617659 pixels (78%) over 1e-06\r\n  1617659 pixels (78%) over 1e-06\r\nFAILURE\r\n<\/pre>\n<p><a href=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-2X.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2634\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-2X-500x281.png\" alt=\"\" width=\"500\" height=\"281\" srcset=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-2X-500x281.png 500w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-2X-1024x576.png 1024w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-2X-768x432.png 768w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-2X-1536x864.png 1536w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-2X-1200x675.png 1200w, https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2026\/02\/diff-2X.png 1920w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><\/p>\n<p>Again, in the scaled version of the diff image we see that the fine details are were the very small differences are. Try opening the full images, one in each tab and toggling between them &#8211; can you see any changes? Yes, we know there are differences &#8211; the smaller file is 1\/3 of the size &#8211; but is this enough to matter? Or even notice?<\/p>\n<p>I&#8217;m going to continue to use <a href=\"https:\/\/www.makemkv.com\/\">MakeMKV<\/a> to rip blu-rays of movies I consider &#8216;reference material&#8217; &#8211; like <a href=\"https:\/\/www.imdb.com\/title\/tt1160419\">Dune<\/a>, because I want all the bits. However, if it&#8217;s just some TV show I captured OTA and I&#8217;m going to watch once, or at most a handful of times &#8211; I&#8217;ll take the space savings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are lots of good reasons to run a media server at home to host your own content. There are also plenty of legitimate ways to get content, but also many that are less so. I think it is important to pay creators for their efforts, I also really like &#8220;owning&#8221; the media I enjoy &hellip; <a href=\"https:\/\/lowtek.ca\/roo\/2026\/re-encoding-transcoding-video-for-space-savings\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Re-encoding\/transcoding video for space savings&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,12],"tags":[],"class_list":["post-2624","post","type-post","status-publish","format-standard","hentry","category-home-theater","category-how-to"],"_links":{"self":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/2624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/comments?post=2624"}],"version-history":[{"count":10,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/2624\/revisions"}],"predecessor-version":[{"id":2641,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/2624\/revisions\/2641"}],"wp:attachment":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/media?parent=2624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/categories?post=2624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/tags?post=2624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}