Add animated AVIF (or AVIS) support#134
Conversation
Signed-off-by: Stefan Oltmann <github@stefan-oltmann.de>
…for unbuffered or streaming sources. This is error-prone.
- ImageFormat -> MediaFormat - ImageMetadata -> MediaMetadata - PhotoRating -> ExifRating - PhotoMetadata -> MetadataSummary Added MediaFormats MP4, MOV & PDF In the future Kim should also extract metadata from video files.
|
@ramonbouckaert That's an awesome contribution! :) Unfortunately I don't think that someone at Ashampoo will ever pull this. :/ I continue the work on my fork https://github.com/stefanOltmann/kim If you could make your PR there, I would love to pull it. :) |
No worries! I'll leave this PR open just in case, but make a PR on your fork now. |
Signed-off-by: Ramon Bouckaert <ramon@bouckaert.com.au>
Signed-off-by: Ramon Bouckaert <ramon@bouckaert.com.au>
… XMP data Signed-off-by: Ramon Bouckaert <ramon@bouckaert.com.au>
cfc135d to
49b6f6d
Compare
Signed-off-by: Ramon Bouckaert <ramon@bouckaert.com.au>
Signed-off-by: Ramon Bouckaert <ramon@bouckaert.com.au>
Signed-off-by: Ramon Bouckaert <ramon@bouckaert.com.au>
|
On second thoughts, closing this PR to focus on the fork at https://github.com/stefanOltmann/kim as the codebase has diverged too much |
Overview
While trying to use this library for a hobby project, I noticed that animated AVIF files were not being parsed by this library.
There are a few problems that prevented this:
ftypavifwhile animated AVIFs areftypavis(which stands for AV1 Image Sequence)TRAKboxes, animated AVIFs have >=2.METAboxes that are sub-boxes of other boxes. While nestedMETAboxes are rarely seen in the wild for non-animated AVIF images, they are commonplace for animated AVIFs, and they are supported in the ISO BMFF: https://b.goeswhere.com/ISO_IEC_14496-12_2015.pdf In the best case, these nested META boxes lead to misleading exceptions being thrown by Kim, but in the worst case they completely confuse Kim's metadata extraction.METAbox with an item type of mime.There is an older approach, described briefly in Adobe's XMP specification (https://github.com/adobe/XMP-Toolkit-SDK/blob/main/docs/XMPSpecificationPart3.pdf) on page 16. Files that use this approach instead embed XMP data in
UUIDboxes - sometimes at the top level, and sometimes nested insideMOOVboxes. Unfortunately I found lots of animated AVIFs in the wild that store XMP data in this way, probably because that's what exiftool appears to do.This pull request enhances the BMFF image parser to support animated AVIFs, and allows Kim to identify and parse such files.
Changes
ftypavismagic number for identifying animated AVIF files (also known as AV1 Image Sequence)TRAKboxes, allowing for >=2 boxes and introducing a new class for the the Track Header BoxBoxReader.readBoxes(...)asparentBoxType, to give theBoxReadervisibility of whether a box is top-level or not.MetaBoxis split into two classes:MetaBoxandMetaBoxTopLevel, the latter of which represents aMETAbox that is not a sub box of some other box. The top-levelMETAbox is where our EXIF and XMP data actually live.BoxReaderparsesMETAboxes differently depending on whether they appear at the top level of the file, or if they're a sub-box of some other box.BoxReader.readBoxes(...)has smarter logic forstopAfterMetadataRead = true- it will continue reading until it has found XMP data in either aMETAbox or aUUIDbox.BaseMediaFileFormatImageParserwill try to find XMP data inUUIDboxes if it cannot be found in theMETAbox.photo_84.avif,photo_85.avif,photo_86.avif, which is used by existing tests to ensure accurate metadata extraction. Each one embeds its XMP data differently to test three cases I observer in real-life animated AVIFS: XMP data in theMETAbox, XMP data in a top-levelUUIDbox, and XMP data in a nestedUUIDbox.BoxReaderTesthas been fleshed out so that it tests reading boxes from HEIC, AVIF and animated AVIF test images, rather than just HEIC.