Dominik Schmidt created TIKA-4869:
-------------------------------------
Summary: Emit the video of a motion photo as an embedded document
Key: TIKA-4869
URL: https://issues.apache.org/jira/browse/TIKA-4869
Project: Tika
Issue Type: Improvement
Reporter: Dominik Schmidt
Tika exposes the Motion Photo and MicroVideo XMP of Google/Android motion
photos, but not the video itself, although both formats say where it is and
every byte of it is already in the file.
The MP4 is appended after the JPEG:
- Motion Photo (Camera:MotionPhoto): Container:Directory lists the items in
file order, the primary image first, the rest tightly packed after it, each
with an Item:Length and an optional Item:Padding. The video starts at
fileLength minus the lengths of the items from the video to the end; in
practice it is the last one, also in Ultra HDR files, where the spec puts the
gain map before it.
- MicroVideo (the older Camera:MicroVideo / GCamera): Camera:MicroVideoOffset
is the number of bytes from the end of the file, so the video starts at
fileLength minus that value.
Proposal: the image parsers emit those bytes as an embedded document,
ATTACHMENT, named motion-photo.<ext>. What is at the computed offset is
detected by content, without the declared Item:Mime as a hint (a hint would
make a wrong length pass as video/mp4 anyway), and nothing is emitted when
detection finds no type: a wrong or hostile length then yields no embedded
document rather than a bogus one. Extraction follows the usual embedded
document limits; a client that does not want the video filters by type as usual.
The same computation covers HEIC and AVIF motion photos, whose XMP goes through
the same extractor: there the video sits in an mpvd box, but that box is last
and its 8 byte header is the primary item's Padding, so the video still ends at
the end of the file. Putting the extraction in the shared image parser base
rather than in JpegParser therefore covers them too, untested for lack of a
sample file.
Apple Live Photos are a different thing and need nothing here: their video is a
separate .MOV, paired by a content identifier, so a HEIC alone carries no video.
The existing test files (testJPEG_MotionPhoto.jpg, testJPEG_MicroVideo.jpg)
declare a video in their XMP but do not contain one; new fixtures with a small
real MP4 appended are needed.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)