{"id":3564,"date":"2011-09-07T21:29:30","date_gmt":"2011-09-08T04:29:30","guid":{"rendered":"http:\/\/multimedia.cx\/eggs\/?p=3564"},"modified":"2011-09-07T21:36:59","modified_gmt":"2011-09-08T04:36:59","slug":"playing-with-file","status":"publish","type":"post","link":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/","title":{"rendered":"Playing With File"},"content":{"rendered":"<p>I played with <a href=\"http:\/\/en.wikipedia.org\/wiki\/File_(command)\">the &#8216;file&#8217; utility<\/a> a long time ago because I wanted to make it recognize a large number of multimedia formats. I had trouble getting my changes to take. But I&#8217;m prepared to try again after many years.<\/p>\n<p><strong>Aiming at the Corpus<\/strong><br \/>\nIn my <a href=\"http:\/\/multimedia.cx\/eggs\/curator-of-the-samples-archive\/\">local mirror of the MPlayerHQ samples archive<\/a>, I find 9853 unique files. So I run all of them through the &#8216;file&#8217; command:<\/p>\n<pre>\r\n  'find \/path\/to\/samples -type f -print0 | xargs -0 file --no-pad'\r\n<\/pre>\n<p>My Ubuntu installation has file v5.04. I also tested against 5.07 and the latest, 5.08. Here is the number of files each version was unable to identify (generically marking as &#8216;data&#8217;):<\/p>\n<pre>\r\n5.04  1521\r\n5.07  1405\r\n5.08  1501\r\n<\/pre>\n<p>That seems like a regression for v5.08 until I dug into the details and saw quite a few items like this, indicating that the MPEG detection could use some work:<\/p>\n<pre>\r\n-mov\/mov-demux-infinite-loop.mpg: DOS-executable (\r\n+mov\/mov-demux-infinite-loop.mpg: data\r\n-image-samples\/UNeedQT4.pntg: DOS-executable (\r\n+image-samples\/UNeedQT4.pntg: data\r\n<\/pre>\n<p><strong>Workflow<\/strong><br \/>\nThese are just notes to myself and perhaps anyone else who wants to add new file formats to be identified by the &#8216;file&#8217; command.<\/p>\n<p>First, download either the <a href=\"ftp:\/\/ftp.astron.com\/pub\/file\/\">latest release from the FTP<\/a> or <a href=\"https:\/\/github.com\/glensc\/file\">clone from Github<\/a>. Do the usual unpack, &#8216;.\/configure&#8217;, &#8216;make&#8217; routine. To use this newly-built version and its associated magic file:<\/p>\n<pre>\r\n  .\/src\/file --magic-file magic\/magic.mgc &lt;file&gt;\r\n<\/pre>\n<p>To add a new format for ID, first, run the foregoing command to ensure that it&#8217;s not already identified. Then, check over the files in magic\/Magdir and see which one might pertain to what you&#8217;re doing (it&#8217;s unlikely that your format will merit a new file in this directory). For example, for this round, I modified animation, audio, iff, and riff. Add or modify existing specs based on the copious examples in the directory and by consulting the appropriate man page (&#8216;man 5 magic&#8217;).<\/p>\n<p>Finally, run &#8216;make&#8217; again which will regenerate the magic file. Invoke the above command again to use the modified magic file.<\/p>\n<p><strong>Before and After<\/strong><br \/>\nOn a selection of formats taken from the samples archive (renamed and cut down to a kilobyte because detection typically only relies on the first few bytes), here is the &#8220;before&#8221;:<\/p>\n<pre>\r\namv:            RIFF (little-endian) data\r\narmovie:        data\r\nbbc-dirac:      data\r\ninterplay-mve:  data\r\nmtv:            data\r\nnintendo-thp:   data\r\nnullsoft-video: data\r\nredcode:        data\r\nsega-film:      data\r\nsmacker:        data\r\ntrueaudio:      data\r\nvqa:            IFF data\r\nwavpack:        data\r\nwc3-mve:        IFF data\r\nwtv:            data\r\n<\/pre>\n<p>And the &#8220;after&#8221;:<\/p>\n<pre>\r\namv:            RIFF (little-endian) data, AMV \r\narmovie:        ARMovie\r\nbbc-dirac:      BBC Dirac Video\r\ninterplay-mve:  Interplay MVE Movie\r\nmtv:            MTV Multimedia File\r\nnintendo-thp:   Nintendo THP Multimedia\r\nnullsoft-video: Nullsoft Video\r\nredcode:        REDCode Video\r\nsega-film:      Sega FILM\/CPK Multimedia, 320 x 224\r\nsmacker:        RAD Game Tools Smacker Multimedia version 2, 320 x 200, 100 frames\r\ntrueaudio:      True Audio Lossless Audio\r\nvqa:            IFF data, Westwood Studios VQA Multimedia, 418 video frames, 320 x 200\r\nwavpack:        WavPack Lossless Audio\r\nwc3-mve:        IFF data, Wing Commander III Video, PC version\r\nwtv:            Windows Television DVR Media\r\n<\/pre>\n<p>After rerunning &#8216;file&#8217; on the mphq corpus using the modified magic file, only 1329 files remain unidentified (down from 1501).<\/p>\n<p><strong>Going Forward<\/strong><br \/>\nAs mentioned, MPEG detection could probably be strengthened. However, a major weakness is QuickTime\/MP4. Many files are not detected, probably owing to the many ways that QuickTime files can begin.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Making the &#8216;file&#8217; utility recognize a few more multimedia formats<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3564","post","type-post","status-publish","format-standard","hentry","category-general"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Making the &#039;file&#039; utility recognize a few more multimedia formats\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Multimedia Mike\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/multimedia.cx\/eggs\/playing-with-file\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Breaking Eggs And Making Omelettes | Topics On Multimedia Technology and Reverse Engineering\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Playing With File | Breaking Eggs And Making Omelettes\" \/>\n\t\t<meta property=\"og:description\" content=\"Making the &#039;file&#039; utility recognize a few more multimedia formats\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/multimedia.cx\/eggs\/playing-with-file\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2011-09-08T04:29:30+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2011-09-08T04:36:59+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Playing With File | Breaking Eggs And Making Omelettes\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Making the &#039;file&#039; utility recognize a few more multimedia formats\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/#article\",\"name\":\"Playing With File | Breaking Eggs And Making Omelettes\",\"headline\":\"Playing With File\",\"author\":{\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/author\\\/multimedia-mike\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/#organization\"},\"datePublished\":\"2011-09-07T21:29:30-07:00\",\"dateModified\":\"2011-09-07T21:36:59-07:00\",\"inLanguage\":\"en-US\",\"commentCount\":7,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/#webpage\"},\"articleSection\":\"General\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/multimedia.cx\\\/eggs\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/category\\\/general\\\/#listItem\",\"name\":\"General\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/category\\\/general\\\/#listItem\",\"position\":2,\"name\":\"General\",\"item\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/category\\\/general\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/#listItem\",\"name\":\"Playing With File\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/#listItem\",\"position\":3,\"name\":\"Playing With File\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/category\\\/general\\\/#listItem\",\"name\":\"General\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/#organization\",\"name\":\"Breaking Eggs And Making Omelettes\",\"description\":\"Topics On Multimedia Technology and Reverse Engineering\",\"url\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/author\\\/multimedia-mike\\\/#author\",\"url\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/author\\\/multimedia-mike\\\/\",\"name\":\"Multimedia Mike\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2eb93f7cada658f7986b5092062849fa255779eada3342c8f6b9a40764b95fdd?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Multimedia Mike\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/#webpage\",\"url\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/\",\"name\":\"Playing With File | Breaking Eggs And Making Omelettes\",\"description\":\"Making the 'file' utility recognize a few more multimedia formats\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/playing-with-file\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/author\\\/multimedia-mike\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/author\\\/multimedia-mike\\\/#author\"},\"datePublished\":\"2011-09-07T21:29:30-07:00\",\"dateModified\":\"2011-09-07T21:36:59-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/#website\",\"url\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/\",\"name\":\"Breaking Eggs And Making Omelettes\",\"description\":\"Topics On Multimedia Technology and Reverse Engineering\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/multimedia.cx\\\/eggs\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Playing With File | Breaking Eggs And Making Omelettes","description":"Making the 'file' utility recognize a few more multimedia formats","canonical_url":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/#article","name":"Playing With File | Breaking Eggs And Making Omelettes","headline":"Playing With File","author":{"@id":"https:\/\/multimedia.cx\/eggs\/author\/multimedia-mike\/#author"},"publisher":{"@id":"https:\/\/multimedia.cx\/eggs\/#organization"},"datePublished":"2011-09-07T21:29:30-07:00","dateModified":"2011-09-07T21:36:59-07:00","inLanguage":"en-US","commentCount":7,"mainEntityOfPage":{"@id":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/#webpage"},"isPartOf":{"@id":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/#webpage"},"articleSection":"General"},{"@type":"BreadcrumbList","@id":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/multimedia.cx\/eggs#listItem","position":1,"name":"Home","item":"https:\/\/multimedia.cx\/eggs","nextItem":{"@type":"ListItem","@id":"https:\/\/multimedia.cx\/eggs\/category\/general\/#listItem","name":"General"}},{"@type":"ListItem","@id":"https:\/\/multimedia.cx\/eggs\/category\/general\/#listItem","position":2,"name":"General","item":"https:\/\/multimedia.cx\/eggs\/category\/general\/","nextItem":{"@type":"ListItem","@id":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/#listItem","name":"Playing With File"},"previousItem":{"@type":"ListItem","@id":"https:\/\/multimedia.cx\/eggs#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/#listItem","position":3,"name":"Playing With File","previousItem":{"@type":"ListItem","@id":"https:\/\/multimedia.cx\/eggs\/category\/general\/#listItem","name":"General"}}]},{"@type":"Organization","@id":"https:\/\/multimedia.cx\/eggs\/#organization","name":"Breaking Eggs And Making Omelettes","description":"Topics On Multimedia Technology and Reverse Engineering","url":"https:\/\/multimedia.cx\/eggs\/"},{"@type":"Person","@id":"https:\/\/multimedia.cx\/eggs\/author\/multimedia-mike\/#author","url":"https:\/\/multimedia.cx\/eggs\/author\/multimedia-mike\/","name":"Multimedia Mike","image":{"@type":"ImageObject","@id":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/2eb93f7cada658f7986b5092062849fa255779eada3342c8f6b9a40764b95fdd?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Multimedia Mike"}},{"@type":"WebPage","@id":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/#webpage","url":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/","name":"Playing With File | Breaking Eggs And Making Omelettes","description":"Making the 'file' utility recognize a few more multimedia formats","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/multimedia.cx\/eggs\/#website"},"breadcrumb":{"@id":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/#breadcrumblist"},"author":{"@id":"https:\/\/multimedia.cx\/eggs\/author\/multimedia-mike\/#author"},"creator":{"@id":"https:\/\/multimedia.cx\/eggs\/author\/multimedia-mike\/#author"},"datePublished":"2011-09-07T21:29:30-07:00","dateModified":"2011-09-07T21:36:59-07:00"},{"@type":"WebSite","@id":"https:\/\/multimedia.cx\/eggs\/#website","url":"https:\/\/multimedia.cx\/eggs\/","name":"Breaking Eggs And Making Omelettes","description":"Topics On Multimedia Technology and Reverse Engineering","inLanguage":"en-US","publisher":{"@id":"https:\/\/multimedia.cx\/eggs\/#organization"}}]},"og:locale":"en_US","og:site_name":"Breaking Eggs And Making Omelettes | Topics On Multimedia Technology and Reverse Engineering","og:type":"article","og:title":"Playing With File | Breaking Eggs And Making Omelettes","og:description":"Making the 'file' utility recognize a few more multimedia formats","og:url":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/","article:published_time":"2011-09-08T04:29:30+00:00","article:modified_time":"2011-09-08T04:36:59+00:00","twitter:card":"summary","twitter:title":"Playing With File | Breaking Eggs And Making Omelettes","twitter:description":"Making the 'file' utility recognize a few more multimedia formats"},"aioseo_meta_data":{"post_id":"3564","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-31 21:46:35","updated":"2025-12-31 19:41:04","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/multimedia.cx\/eggs\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/multimedia.cx\/eggs\/category\/general\/\" title=\"General\">General<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tPlaying With File\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/multimedia.cx\/eggs"},{"label":"General","link":"https:\/\/multimedia.cx\/eggs\/category\/general\/"},{"label":"Playing With File","link":"https:\/\/multimedia.cx\/eggs\/playing-with-file\/"}],"_links":{"self":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3564","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=3564"}],"version-history":[{"count":11,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3564\/revisions"}],"predecessor-version":[{"id":3576,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3564\/revisions\/3576"}],"wp:attachment":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/media?parent=3564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/categories?post=3564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/tags?post=3564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}