Commit bb79091
authored
* [TIKA-4777] Expose presentation start of delayed QuickTime timed metadata tracks
QuickTime timed metadata tracks (mebx sample descriptions, ISO 14496-12
boxed metadata) declare their key names in the file, and the track's
presentation start is defined by its edit list: a leading empty edit
delays the media by its duration. Parse the mebx key declarations
(keys/keyd) and emit, for every declared key of a delayed track, the
presentation start in microseconds as <key name>.track-start-us.
Undelayed tracks (start 0) are not reported, their start carries no
information.
This is deliberately generic, no key names are hardcoded. The main use
case are Apple Live Photos, which mark the moment the paired still
image was captured as the single one-tick sample of the
still-image-time track, shifted to that moment by an empty edit. The
sample value itself is a constant -1 marker, so the moov boxes alone
are sufficient and mdat is never touched.
The handler stays active for timed metadata tracks (handler type
'meta') instead of switching to the extraction-free Mp4MetaHandler,
which would keep it from seeing the track's stsd.
Verified against a real Live Photo video (iPhone 15 Pro, iOS 18.5):
com.apple.quicktime.still-image-time.track-start-us = 1233333 (1.2333s,
matching the empty edit of 740/600s), likewise the transform keys of
the same track; the undelayed video-orientation and live-photo-info
tracks are not reported.
* [TIKA-4777] Address review feedback: reuse Mp4MetaHandler, fix edit list handling
Architecture: instead of suppressing the base handler's Mp4MetaHandler and
accepting minf/stbl/stsd globally (which also slurped the sample
descriptions of unrelated track types), return a TikaMp4MetaHandler
subclass from the hdlr branch. The base Mp4MediaHandler already routes the
track's stsd and stts; the subclass fills in the empty
processSampleDescription/processTimeToSample overrides. This also keeps
Mp4MetaDirectory alive. The redundant processMovieTimescale is replaced by
the movie timescale the base handler already stores
(Mp4Directory.TAG_TIME_SCALE).
Edit list correctness: only leading empty edits delay a track, so the scan
stops at the first normal entry and sums consecutive leading empty edits
instead of picking the first -1 entry anywhere. The per-track state is now
reset when the trak container starts rather than at tkhd, making it
independent of box order, and the microsecond conversion is guarded
against overflow.
Sample count invariant: the track start is only the time of the still
sample because the track has exactly one sample, so stts is now read and
tracks with more than one sample are not reported (previously the delay
filter only correlated with this).
Tests: the crafted fixture now has realistic track plumbing (gmhd,
dhlr/alis data handler, dinf/dref, full stsd/stts/stsc/stsz/stco) and
three additional timed metadata tracks covering a version-1 edit list, a
non-leading empty edit directly after the delayed track (state leak
probe), and a delayed multi-sample track. Emission uses add() instead of
set() so distinct tracks declaring the same key do not silently overwrite.
* [TIKA-4777] Replace per-key track-start suffix with quicktime:still-image-time
Review outcome: instead of grafting a Tika-invented .track-start-us
suffix onto Apple's key namespace, the presentation start of the
still-image-time track is now a single dedicated property,
quicktime:still-image-time (microseconds). It is emitted for any
single-sample mebx track declaring com.apple.quicktime.still-image-time,
including 0 when the track has no leading empty edit, so "still is the
first frame" (0) stays distinguishable from "not a Live Photo" (absent).
Foreign mebx keys no longer produce any output.
The quicktime: namespace follows the naming used by ExifTool, exiv2 and
metadata-extractor, which all spell out QuickTime; the keys are
container-level and appear identically in audio-only files, so a video:
prefix would be misleading. The unit stays out of the property name per
the convention of xmpDM:duration, geo:alt and audio:bitrate.
New fixture testMP4_StillImageTimeZero.mov covers the undelayed case
(version 1 edit list containing only a media edit).
* [TIKA-4777] Reject oversized stsd entry sizes and cover the edit list reset
A crafted sample description declaring an entry size like 0xFFFFFFFF
passed the < 16 guard, turned negative in the int cast and escaped
parse() as a NegativeArraySizeException. Entry sizes beyond the
remaining payload are now treated as malformed; the regression test
reproduces the escape when the guard is removed.
The still-image-time zero fixture now places a delayed foreign-key
track before the undelayed track, so an empty edit duration leaking
between tracks would surface as a non-zero value in the existing
assertion. Also collapses leftover blank lines in TikaMp4BoxHandler.
* [TIKA-4777] Fix static import order for spotless
1 parent 39e83a8 commit bb79091
6 files changed
Lines changed: 334 additions & 2 deletions
File tree
- tika-core/src/main/java/org/apache/tika/metadata
- tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src
- main/java/org/apache/tika/parser/mp4
- test
- java/org/apache/tika/parser/mp4
- resources/test-documents
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
Lines changed: 74 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
59 | 65 | | |
60 | 66 | | |
61 | 67 | | |
| |||
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
68 | | - | |
| 74 | + | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
75 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
76 | 88 | | |
77 | 89 | | |
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
81 | 93 | | |
82 | 94 | | |
83 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
87 | 103 | | |
88 | 104 | | |
89 | 105 | | |
90 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
91 | 120 | | |
92 | 121 | | |
93 | 122 | | |
| |||
177 | 206 | | |
178 | 207 | | |
179 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
180 | 248 | | |
181 | 249 | | |
182 | 250 | | |
| |||
225 | 293 | | |
226 | 294 | | |
227 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
228 | 300 | | |
Lines changed: 174 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
0 commit comments