{"id":2599,"date":"2010-07-14T20:55:55","date_gmt":"2010-07-15T03:55:55","guid":{"rendered":"http:\/\/multimedia.cx\/eggs\/?p=2599"},"modified":"2020-07-25T22:53:11","modified_gmt":"2020-07-26T05:53:11","slug":"brute-force-dimensional-analysis","status":"publish","type":"post","link":"https:\/\/multimedia.cx\/eggs\/brute-force-dimensional-analysis\/","title":{"rendered":"Brute Force Dimensional Analysis"},"content":{"rendered":"<p>I was poking at the data files of a really bad <em>(is there any other kind?)<\/em> interactive movie video game known simply by one letter: <a href=\"http:\/\/games.multimedia.cx\/d-the-game\/\"><em>D<\/em><\/a>. The Sega Saturn version of the game is comprised primarily of Sega FILM\/CPK files, <a href=\"http:\/\/wiki.multimedia.cx\/index.php?title=Sega_FILM\">about which I wrote the book<\/a>. The second most prolific file type bears the extension &#8216;.dg2&#8217;. Cursory examination of sample files revealed an apparently headerless format. Many of the video files are 288&#215;144 in resolution. Multiplying that width by that height and then doubling it (as in, 2 bytes\/pixel) yields 82944, which happens to be the size of a number of these DG2 files. Now, if only I had a tool that could take a suspected raw RGB file and convert it to a more standard image format.<\/p>\n<p>Here&#8217;s the <a href=\"http:\/\/ffmpeg.org\/\">FFmpeg<\/a> conversion recipe I used:<\/p>\n<pre>\r\n ffmpeg -f rawvideo -pix_fmt rgb555 -s 288x144 -i raw_file -y output.png\r\n<\/pre>\n<p>So that covers the files that are suspected to be 288&#215;144 in dimension. But what about other file sizes? My brute force approach was to try all possible dimensions that would yield a particular file size. The Python code for performing this operation is listed at the end of this post.<\/p>\n<p>It&#8217;s interesting to view the progression as the script compresses to different sizes:<\/p>\n<p><center><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2010\/07\/d-progression.png\" alt=\"\" title=\"D: The progression\" width=\"297\" height=\"355\" class=\"aligncenter size-full wp-image-2600\" srcset=\"https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2010\/07\/d-progression.png 297w, https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2010\/07\/d-progression-250x300.png 250w\" sizes=\"auto, (max-width: 297px) 100vw, 297px\" \/><br \/>\n<\/center><\/p>\n<p><a href=\"http:\/\/www.mobygames.com\/game\/d\">That &#8216;D&#8217; is supposed to be red<\/a>. So right away, we see that rgb555(le) is not the correct input format. Annoyingly, FFmpeg cannot handle rgb5[5|6]5be as a raw input format. But this little project worked well enough as a proof of concept.<\/p>\n<p>If you want to toy around with these files (and I know you do), I have uploaded a selection at: <a href=\"http:\/\/multimedia.cx\/dg2\/\">http:\/\/multimedia.cx\/dg2\/<\/a>.<\/p>\n<p>Here is my quick Python script for converting one of these files to every acceptable resolution.<\/p>\n<p>work-out-resolution.py:<br \/>\n<!--more--><br \/>\n<script src=\"https:\/\/gist.github.com\/multimediamike\/aee35eb93e3c014d4c5a67d2e23a90a7.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was poking at the data files of a really bad (is there any other kind?) interactive movie video game known simply by one letter: D. The Sega Saturn version of the game is comprised primarily of Sega FILM\/CPK files, about which I wrote the book. The second most prolific file type bears the extension [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,55],"tags":[],"class_list":["post-2599","post","type-post","status-publish","format-standard","hentry","category-game-hacking","category-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/2599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/comments?post=2599"}],"version-history":[{"count":8,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/2599\/revisions"}],"predecessor-version":[{"id":4604,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/2599\/revisions\/4604"}],"wp:attachment":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/media?parent=2599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/categories?post=2599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/tags?post=2599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}