{"id":2279,"date":"2023-06-03T10:53:11","date_gmt":"2023-06-03T08:53:11","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=2279"},"modified":"2023-06-03T10:55:07","modified_gmt":"2023-06-03T08:55:07","slug":"windows-mp4-shell-property-handler-sometimes-destroys-your-media-data","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/2279","title":{"rendered":"Windows MP4 shell property handler sometimes destroys your media data"},"content":{"rendered":"\n<p>Some version of Microsoft Windows OS have rather dangerous subsystem known as MP4 property sheet handler (&#8220;MF MPEG-4 Property Handler&#8221; to be exact). Programmatically, you would use API like <code><a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/shobjidl_core\/nf-shobjidl_core-shgetpropertystorefromparsingname\">SHGetPropertyStoreFromParsingName<\/a><\/code> and use <code>IPropertyStore<\/code> from there to read (reading is OK) and update\/write certain MP4 file properties like, for example, a comment or som other metadata.<\/p>\n\n\n\n<p>The same API is used from property sheet UI if you decide to update metadata:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"412\" height=\"600\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2023\/06\/image-412x600.png\" alt=\"\" class=\"wp-image-2280\" srcset=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2023\/06\/image-412x600.png 412w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2023\/06\/image-220x320.png 220w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2023\/06\/image-600x874.png 600w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2023\/06\/image.png 711w\" sizes=\"auto, (max-width: 412px) 100vw, 412px\" \/><\/figure>\n\n\n\n<p>It looks like the implementation is damaging some media files. An attempt to update a file breaks it and overwrites vital part of MPEG-4 Part 14 file structure with the new metadata, rendering the file unplayable.<\/p>\n\n\n\n<p>Long story short &#8211; <strong>prefer to not use the API at all to update the metadata<\/strong>, or make a backup copy.<\/p>\n\n\n\n<p>In DirectShow MP4 multiplexer created back in time <a href=\"https:\/\/gdcl.co.uk\/mpeg4\/\">by Geraint Davies<\/a>, in <a href=\"https:\/\/github.com\/roman380\/gdcl.co.uk-mpeg4\">its fork<\/a> I am still using somewhere, I created <code><a href=\"https:\/\/github.com\/roman380\/gdcl.co.uk-mpeg4\/blob\/master\/mp4mux\/mp4mux.idl#L59\">IMuxFilter::SetComment<\/a><\/code> method exactly for this: to be able to set comment before the file is finalized, by injecting a respective box with metadata as a part of finalization, so that stock faulty Windows API is not used and the produced file is reliably safe.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some version of Microsoft Windows OS have rather dangerous subsystem known as MP4 property sheet handler (&#8220;MF MPEG-4 Property Handler&#8221; to be exact). Programmatically, you would use API like SHGetPropertyStoreFromParsingName and use IPropertyStore from there to read (reading is OK) and update\/write certain MP4 file properties like, for example, a comment or som other metadata.&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/2279\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,78,628,470,168,150],"class_list":["post-2279","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-api","tag-directshow","tag-metadata","tag-mp4","tag-shell","tag-windows"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/2279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=2279"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/2279\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=2279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=2279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=2279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}