Add MacOS metadata to files
Problem
MacOS is capable of exposing some movie-related metadata, but it can’t read the kind Subler adds inside the file. This is a flaw within Finder IMHO, but I don’t expect it will change anytime soon.
Proposed Solution
Add some metadata fields to the file so that MacOS can index that information.
Current Example
Note: I will use an example movie file
Movies/Aloha (2015. 1080p).mp4
throughout this issue. This example file has already been processed by Subler and has all the complete and correct metadata.
To view the metadata available to MacOS, which it can display in finder and index with spotlight, run mdls
from the command line and see the following result:
$ mdls Aloha\ \(2015.\ 1080p\).mp4
_kMDItemDisplayNameWithExtensions = "Aloha (2015. 1080p).mp4"
kMDItemAudioBitRate = 93
kMDItemAudioChannelCount = 2
kMDItemCodecs = (
"H.264",
AAC
)
kMDItemContentCreationDate = 2015-09-21 18:13:04 +0000
kMDItemContentCreationDate_Ranking = 2015-09-21 00:00:00 +0000
kMDItemContentModificationDate = 2016-07-20 11:54:48 +0000
kMDItemContentModificationDate_Ranking = 2016-07-20 00:00:00 +0000
kMDItemContentType = "public.mpeg-4"
kMDItemContentTypeTree = (
"public.mpeg-4",
"public.movie",
"public.audiovisual-content",
"public.data",
"public.item",
"public.content"
)
kMDItemDateAdded = 2018-07-10 12:24:08 +0000
kMDItemDateAdded_Ranking = 2018-07-10 00:00:00 +0000
kMDItemDisplayName = "Aloha (2015. 1080p).mp4"
kMDItemDocumentIdentifier = 0
kMDItemDurationSeconds = 6278.335
kMDItemFSContentChangeDate = 2016-07-20 11:54:48 +0000
kMDItemFSCreationDate = 2015-09-21 18:13:04 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = "Aloha (2015. 1080p).mp4"
kMDItemFSNodeCount = 1763543816
kMDItemFSOwnerGroupID = 99
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 1763543816
kMDItemFSTypeCode = ""
kMDItemInterestingDate_Ranking = 2016-07-20 00:00:00 +0000
kMDItemKind = "MPEG-4 movie"
kMDItemLogicalSize = 1763543816
kMDItemMediaTypes = (
Video,
Sound
)
kMDItemPhysicalSize = 1763549184
kMDItemPixelHeight = 1040
kMDItemPixelWidth = 1920
kMDItemStreamable = 0
kMDItemTotalBitRate = 2242
kMDItemVideoBitRate = 2149
And you can see that this corresponds with what appears in Finder’s preview pane (left). The values added by Subler are on the right.
Proposed Metadata Mapping
Metadata can be added to the file using Apple’s Core Spotlight framework. While it is possible to create custom attributes, the framework provides several default attributes for media (linked below) that only need to have mapped values set. Those defaults would likely be sufficient for most users. Here is my proposed mapping:
Subler “Annotation” Meta Key | Core Spotlight Meta Key | Example Value |
---|---|---|
Release Date | Copyright (Year only) | Copyright : String? A list of companies or organizations that created the content. | String: 2015 |
Studio | Organizations : [String]? A list of companies or organizations that created the content. | Array: Columbia Pictures, Vinyl Films, Regency Enterprises, Sony Pictures Entertainment (SPE), RatPac Entertainment, LStar Capital |
Cast | Performers : [String]? A list of performers in the media. | Array: Bradley Cooper, Emma Stone, Rachel McAdams, John Krasinski, Bill Murray, Alec Baldwin, Danny McBride, Danielle Rose Russell, Edi Gathegi, Jaeden Lieberher, Michael Chernus, Sugar Lyn Beard, Elizabeth Marvel, Ivana Miličević, Kelly Oxford |
Producers && Executive Producers (Except the first EP value) | Contributors : [String]? A list of people, organizations, or services that made contributions to the media content. | Array: |
Executive Producers (First EP only) | Producer : String? The producer of the content | Eli Bush |
Genre (First value only) | Genre : String? | Adventure |
Director | Director : String? | Cameron Crowe |
Description | contentDescription : String? | A celebrated military contractor returns to the site of his greatest career triumphs and re-connects with a long-ago love while unexpectedly falling for the hard-charging Air Force watchdog assigned to him. |
Media Kind | Content Type : String? | Movies: kUTTypeMovie TV Shows: kUTTypeAudiovisualContent |
Name | Title : String? | Aloha |
Composer (First value only) | Composer : String? | Jon Thor |
While this mapping is far from perfect (mostly due to representing arrays as strings), it would be a huge improvement over the current options for finding and sorting media within Finder.
Misc
While it is a bit old, at one point OpenMeta was the library often used for handling metadata. I don’t know if the code there is still relevant or useful.
A better maintained project that might also be helpful is MetaZ, although I’ve never used it, so I can’t comment on how good or bad it is.
Comments (2)
-
repo owner -
repo owner - changed status to invalid
- Log in to comment
That’s not how it works. It would break when you move the files to another computer. What you want is a Spotlight Importer with a better understanding of metadata ( https://developer.apple.com/library/archive/documentation/Carbon/Conceptual/MDImporters/Concepts/WritingAnImp.html )