You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "dschmidt (via GitHub)" <gi...@apache.org> on 2026/09/01 21:09:50 UTC
[PR] TIKA-3646: Type a plain MP4 by its tracks, not by its brand [tika]
dschmidt opened a new pull request, #3114:
URL: https://github.com/apache/tika/pull/3114
Tika's own fixtures show the problem: `testMP4Video.mp4` and `testMP4AudioOnly.mp4` both carry the `isom` brand, and both are detected as `video/quicktime`, because the mime magic for `video/mp4` only matches the brands `mp41` and `mp42`. Adding `isom` to that magic would type the audio-only file as video, so the brand cannot answer this; the tracks have to.
`MP4TrackDetector` walks the top level boxes by their size fields, which steps over the media data rather than reading it, finds the movie box and reads the handler type of each `moov/trak/mdia/hdlr`: a video track makes it `video/mp4`, otherwise an audio track makes it `audio/mp4`, otherwise `application/mp4`, as RFC 4337 describes. Brands that name a format of their own (M4A, 3GP, HEIC, AVIF, CR3, ...) are left to their own magic, and so is a file whose movie box cannot be reached.
The box primitives are shared rather than written again: `boxEnd`, `findBox` and the FourCC readers move from `Mp4SampleEntries` (TIKA-4838) into `Mp4Boxes`, which now also handles the 64 bit largesize and the size 0 form; the sample entry walker and the two sample handlers use it.
Bounds, since a detector reads whatever arrives: sizes are checked as longs before any cast, the walk stops at the first box that does not fit what encloses it, the number of boxes and tracks and the size of the movie box read into memory are capped, and without a file to seek in only a movie box within the first 256 KB is found. Tests cover every truncation of a well formed file and random bytes behind a valid header.
Verified on a server built from this branch: `testMP4AudioOnly.mp4` now detects as audio/mp4 and `testMP4Video.mp4` as video/mp4, where both used to be video/quicktime; HEIC, AVIF and M4A files are unchanged.
This closes TIKA-3646 and, for plain MP4, the question in TIKA-2935.
https://issues.apache.org/jira/browse/TIKA-3646
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-3646: Type a plain MP4 by its tracks, not by its brand [tika]
Posted by "dschmidt (via GitHub)" <gi...@apache.org>.
dschmidt closed pull request #3114: TIKA-3646: Type a plain MP4 by its tracks, not by its brand
URL: https://github.com/apache/tika/pull/3114
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-3646: Type a plain MP4 by its tracks, not by its brand [tika]
Posted by "tballison (via GitHub)" <gi...@apache.org>.
tballison commented on PR #3114:
URL: https://github.com/apache/tika/pull/3114#issuecomment-5591382860
> Honestly, having sat with this for a bit: I am not sure any more that it is worth it.
Should we close this out?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-3646: Type a plain MP4 by its tracks, not by its brand [tika]
Posted by "THausherr (via GitHub)" <gi...@apache.org>.
THausherr commented on PR #3114:
URL: https://github.com/apache/tika/pull/3114#issuecomment-5558159129
I partly agree with copilot, because you also have this:
```
byte[] header = boxes.read(position, 16);
if (header == null || header.length < 8) {
return null;
}
```
so you can handle less than 8 bytes. `boxes.read()` should check the length. I disagree with copilot that it returns null whenever fewer than 8 bytes remain, because it would work if less than 8 bytes would be requested. Anyway, it feels kindof weird.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-3646: Type a plain MP4 by its tracks, not by its brand [tika]
Posted by "tballison (via GitHub)" <gi...@apache.org>.
tballison commented on PR #3114:
URL: https://github.com/apache/tika/pull/3114#issuecomment-5500800624
Looks like we have to parse the mp4 in some cases where the right information isn't close enough to the front. For some parsers, we have a pattern where the detector detects family, and then the parser can make more specific, as with Adobe Illustrator and PDFs. There's another parser/detector where we do this too and we make the Detector optional, but it basically just calls the parser.
What would you think of folding this logic into the parser to update the mime type during parse?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-3646: Type a plain MP4 by its tracks, not by its brand [tika]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3114:
URL: https://github.com/apache/tika/pull/3114#discussion_r3916777084
##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/detect/mp4/MP4TrackDetector.java:
##########
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.detect.mp4;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.SeekableByteChannel;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.tika.annotation.TikaComponent;
+import org.apache.tika.detect.Detector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.mime.MediaType;
+import org.apache.tika.parser.ParseContext;
+import org.apache.tika.parser.mp4.Mp4Boxes;
+
+/**
+ * Types a plain MP4 file by what it contains, as RFC 4337 asks: video/mp4
+ * when it has a video track, audio/mp4 when it has only audio, and
+ * application/mp4 when it has neither (TIKA-2935, TIKA-3646).
+ * <p>
+ * The mime magic cannot do this. It only knows the brand in the
+ * {@code ftyp} box, and the brand of the great majority of MP4 files,
+ * {@code isom}, says nothing about their content: Tika's own
+ * {@code testMP4Video.mp4} and {@code testMP4AudioOnly.mp4} both carry it.
+ * Brands that name a format of their own (M4A, 3GP, HEIC, AVIF, CR3, ...)
+ * keep their magic and are left alone here.
+ * <p>
+ * The detector walks the top level boxes by their size fields, which skips
+ * the media data rather than reading it, and reads the handler type of each
+ * track in the movie box. A file whose movie box is unreachable (missing,
+ * beyond the limits below, or not backed by a file) is left to the magic.
+ */
+@TikaComponent
+public class MP4TrackDetector implements Detector {
+
+ private static final long serialVersionUID = 1L;
+
+ static final MediaType MP4_VIDEO = MediaType.video("mp4");
+ static final MediaType MP4_AUDIO = MediaType.audio("mp4");
+ static final MediaType MP4_APPLICATION = MediaType.application("mp4");
+
+ /**
+ * The brands of a plain MP4. A brand naming a specific format is not
+ * here: those files are typed by their own magic.
+ */
+ private static final Set<String> BRANDS = Collections.unmodifiableSet(new HashSet<>(
+ Arrays.asList("isom", "iso2", "iso4", "iso5", "iso6", "mp41", "mp42", "avc1",
+ "mmp4")));
+
+ /**
+ * Bounds the walk over a crafted file: a real one has a handful of top
+ * level boxes and a handful of tracks.
+ */
+ private static final int MAX_BOXES = 256;
+
+ private static final int MAX_TRACKS = 64;
+
+ /**
+ * How much of a movie box is read for its track handlers.
+ */
+ private static final int MAX_MOOV_BYTES = 8 * 1024 * 1024;
+
+ /**
+ * How far into a stream the movie box is looked for before the stream is
+ * spooled: a file written for streaming has it right behind the file type
+ * box, and answering those costs nothing.
+ */
+ private static final int MAX_PREFIX_BYTES = 256 * 1024;
+
+ @Override
+ public MediaType detect(TikaInputStream tis, Metadata metadata, ParseContext parseContext)
+ throws IOException {
+ if (tis == null) {
+ return MediaType.OCTET_STREAM;
+ }
+ tis.mark(16);
+ byte[] header = new byte[16];
+ int read;
+ try {
+ read = IOUtils.read(tis, header, 0, 16);
+ } finally {
+ tis.reset();
+ }
+ if (read < 12 || !isFtyp(header) || !BRANDS.contains(brand(header))) {
+ return MediaType.OCTET_STREAM;
+ }
+ byte[] moov = movieBox(tis);
+ if (moov == null) {
+ return MediaType.OCTET_STREAM;
+ }
+ return byTracks(moov);
+ }
+
+ private static boolean isFtyp(byte[] header) {
+ return header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p';
+ }
+
+ private static String brand(byte[] header) {
+ return new String(header, 8, 4, StandardCharsets.US_ASCII);
+ }
+
+ /**
+ * The movie box, found by walking the top level boxes; null when there
+ * is none within the limits.
+ */
+ private static byte[] movieBox(TikaInputStream tis) throws IOException {
+ if (!tis.hasFile()) {
+ //a movie box at the front is answered without touching the disk
+ tis.mark(MAX_PREFIX_BYTES);
+ byte[] prefix = new byte[MAX_PREFIX_BYTES];
+ int length;
+ try {
+ length = IOUtils.read(tis, prefix, 0, MAX_PREFIX_BYTES);
+ } finally {
+ tis.reset();
+ }
+ byte[] fromPrefix = movieBox(new ArrayBoxes(prefix, Math.max(length, 0)));
+ if (fromPrefix != null) {
+ return fromPrefix;
+ }
+ if (length < MAX_PREFIX_BYTES) {
+ //the whole file was in the prefix, so there is nothing further in
+ return null;
+ }
+ }
+ //a movie box behind the media data, where recorders that do not write
+ //for streaming put it, is only reachable by seeking; the spooled file
+ //is the one the parse reads afterwards, so it is not read twice
+ try (SeekableByteChannel channel = Files.newByteChannel(tis.getPath())) {
+ return movieBox(new ChannelBoxes(channel));
+ }
+ }
+
+ private static byte[] movieBox(Boxes boxes) throws IOException {
+ long position = 0;
+ for (int i = 0; i < MAX_BOXES; i++) {
+ byte[] header = boxes.read(position, 16);
+ if (header == null || header.length < 8) {
+ return null;
+ }
+ long size = uint32(header, 0);
+ int headerSize = 8;
+ if (size == 1) {
+ if (header.length < 16) {
+ return null;
+ }
+ size = uint64(header, 8);
+ headerSize = 16;
+ } else if (size == 0) {
+ size = boxes.length() - position;
+ }
+ if (size < headerSize || position > boxes.length() - size) {
+ return null;
+ }
+ if ("moov".equals(Mp4Boxes.fourCC(header, 4))) {
+ long payload = size - headerSize;
+ if (payload <= 0 || payload > MAX_MOOV_BYTES) {
+ return null;
+ }
+ return boxes.read(position + headerSize, (int) payload);
+ }
+ position += size;
+ }
+ return null;
+ }
+
+ /**
+ * The type of the movie: video where a track says so, else audio, else
+ * neither. The handlers are read where a track keeps them,
+ * {@code moov/trak/mdia/hdlr}, so the handler of the metadata in
+ * {@code moov/udta/meta} is not mistaken for a track.
+ */
+ private static MediaType byTracks(byte[] moov) {
+ boolean audio = false;
+ int trak = Mp4Boxes.findBox(moov, 0, moov.length, "trak", MAX_BOXES);
+ for (int track = 0; trak >= 0 && track < MAX_TRACKS; track++) {
+ int trakEnd = Mp4Boxes.boxEnd(moov, trak, moov.length);
+ if (trakEnd < 0) {
+ break;
+ }
+ String handler = handler(moov, trak, trakEnd);
+ if ("vide".equals(handler)) {
+ return MP4_VIDEO;
+ }
+ audio |= "soun".equals(handler);
+ trak = Mp4Boxes.findBox(moov, trakEnd, moov.length, "trak", MAX_BOXES);
+ }
+ return audio ? MP4_AUDIO : MP4_APPLICATION;
+ }
+
+ /**
+ * The handler type of a track, from {@code mdia/hdlr}, or null.
+ */
+ private static String handler(byte[] moov, int trak, int trakEnd) {
+ int payload = Mp4Boxes.payloadStart(moov, trak, trakEnd);
+ int mdia = payload < 0 ? -1
+ : Mp4Boxes.findBox(moov, payload, trakEnd, "mdia", MAX_BOXES);
+ if (mdia < 0) {
+ return null;
+ }
+ int mdiaEnd = Mp4Boxes.boxEnd(moov, mdia, trakEnd);
+ int mdiaPayload = mdiaEnd < 0 ? -1 : Mp4Boxes.payloadStart(moov, mdia, mdiaEnd);
+ int hdlr = mdiaPayload < 0 ? -1
+ : Mp4Boxes.findBox(moov, mdiaPayload, mdiaEnd, "hdlr", MAX_BOXES);
+ if (hdlr < 0) {
+ return null;
+ }
+ //hdlr: version and flags, pre_defined, then the handler type
+ int handler = hdlr + Mp4Boxes.HEADER + 8;
+ return handler + 4 <= Mp4Boxes.boxEnd(moov, hdlr, mdiaEnd)
+ ? Mp4Boxes.fourCC(moov, handler) : null;
+ }
+
+ private static long uint32(byte[] b, int off) {
+ return ByteBuffer.wrap(b, off, 4).getInt() & 0xFFFFFFFFL;
+ }
+
+ private static long uint64(byte[] b, int off) {
+ return ByteBuffer.wrap(b, off, 8).getLong();
+ }
+
+ /**
+ * The bytes the walk reads from, so the same walk serves a file and a
+ * prefix held in memory.
+ */
+ private interface Boxes {
+ /**
+ * @return the bytes at the offset, or null if they are not there
+ */
+ byte[] read(long offset, int length) throws IOException;
+
+ long length() throws IOException;
+ }
+
+ private static final class ArrayBoxes implements Boxes {
+ private final byte[] bytes;
+ private final int length;
+
+ ArrayBoxes(byte[] bytes, int length) {
+ this.bytes = bytes;
+ this.length = length;
+ }
+
+ @Override
+ public byte[] read(long offset, int size) {
+ if (offset < 0 || offset > length - Math.min(size, 8)) {
+ return null;
+ }
+ int available = (int) Math.min(size, length - offset);
+ return Arrays.copyOfRange(bytes, (int) offset, (int) offset + available);
+ }
Review Comment:
`ArrayBoxes.read()` returns null whenever fewer than 8 bytes remain (`offset > length - Math.min(size, 8)`), even though callers (and `ChannelBoxes.read`) can handle short reads. This makes the `Boxes` abstraction inconsistent and can cause the prefix scan to treat trailing bytes as "not there" instead of "present but truncated", potentially changing walk behavior.
##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/detect/mp4/MP4TrackDetector.java:
##########
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.detect.mp4;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.SeekableByteChannel;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.tika.annotation.TikaComponent;
+import org.apache.tika.detect.Detector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.mime.MediaType;
+import org.apache.tika.parser.ParseContext;
+import org.apache.tika.parser.mp4.Mp4Boxes;
+
+/**
+ * Types a plain MP4 file by what it contains, as RFC 4337 asks: video/mp4
+ * when it has a video track, audio/mp4 when it has only audio, and
+ * application/mp4 when it has neither (TIKA-2935, TIKA-3646).
+ * <p>
+ * The mime magic cannot do this. It only knows the brand in the
+ * {@code ftyp} box, and the brand of the great majority of MP4 files,
+ * {@code isom}, says nothing about their content: Tika's own
+ * {@code testMP4Video.mp4} and {@code testMP4AudioOnly.mp4} both carry it.
+ * Brands that name a format of their own (M4A, 3GP, HEIC, AVIF, CR3, ...)
+ * keep their magic and are left alone here.
+ * <p>
+ * The detector walks the top level boxes by their size fields, which skips
+ * the media data rather than reading it, and reads the handler type of each
+ * track in the movie box. A file whose movie box is unreachable (missing,
+ * beyond the limits below, or not backed by a file) is left to the magic.
+ */
+@TikaComponent
+public class MP4TrackDetector implements Detector {
+
+ private static final long serialVersionUID = 1L;
+
+ static final MediaType MP4_VIDEO = MediaType.video("mp4");
+ static final MediaType MP4_AUDIO = MediaType.audio("mp4");
+ static final MediaType MP4_APPLICATION = MediaType.application("mp4");
+
+ /**
+ * The brands of a plain MP4. A brand naming a specific format is not
+ * here: those files are typed by their own magic.
+ */
+ private static final Set<String> BRANDS = Collections.unmodifiableSet(new HashSet<>(
+ Arrays.asList("isom", "iso2", "iso4", "iso5", "iso6", "mp41", "mp42", "avc1",
+ "mmp4")));
+
+ /**
+ * Bounds the walk over a crafted file: a real one has a handful of top
+ * level boxes and a handful of tracks.
+ */
+ private static final int MAX_BOXES = 256;
+
+ private static final int MAX_TRACKS = 64;
+
+ /**
+ * How much of a movie box is read for its track handlers.
+ */
+ private static final int MAX_MOOV_BYTES = 8 * 1024 * 1024;
+
+ /**
+ * How far into a stream the movie box is looked for before the stream is
+ * spooled: a file written for streaming has it right behind the file type
+ * box, and answering those costs nothing.
+ */
+ private static final int MAX_PREFIX_BYTES = 256 * 1024;
+
+ @Override
+ public MediaType detect(TikaInputStream tis, Metadata metadata, ParseContext parseContext)
+ throws IOException {
+ if (tis == null) {
+ return MediaType.OCTET_STREAM;
+ }
+ tis.mark(16);
+ byte[] header = new byte[16];
+ int read;
+ try {
+ read = IOUtils.read(tis, header, 0, 16);
+ } finally {
+ tis.reset();
+ }
+ if (read < 12 || !isFtyp(header) || !BRANDS.contains(brand(header))) {
+ return MediaType.OCTET_STREAM;
+ }
+ byte[] moov = movieBox(tis);
+ if (moov == null) {
+ return MediaType.OCTET_STREAM;
+ }
+ return byTracks(moov);
+ }
+
+ private static boolean isFtyp(byte[] header) {
+ return header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p';
+ }
+
+ private static String brand(byte[] header) {
+ return new String(header, 8, 4, StandardCharsets.US_ASCII);
+ }
+
+ /**
+ * The movie box, found by walking the top level boxes; null when there
+ * is none within the limits.
+ */
+ private static byte[] movieBox(TikaInputStream tis) throws IOException {
+ if (!tis.hasFile()) {
+ //a movie box at the front is answered without touching the disk
+ tis.mark(MAX_PREFIX_BYTES);
+ byte[] prefix = new byte[MAX_PREFIX_BYTES];
+ int length;
+ try {
+ length = IOUtils.read(tis, prefix, 0, MAX_PREFIX_BYTES);
+ } finally {
+ tis.reset();
+ }
+ byte[] fromPrefix = movieBox(new ArrayBoxes(prefix, Math.max(length, 0)));
+ if (fromPrefix != null) {
+ return fromPrefix;
+ }
+ if (length < MAX_PREFIX_BYTES) {
+ //the whole file was in the prefix, so there is nothing further in
+ return null;
+ }
+ }
+ //a movie box behind the media data, where recorders that do not write
+ //for streaming put it, is only reachable by seeking; the spooled file
+ //is the one the parse reads afterwards, so it is not read twice
+ try (SeekableByteChannel channel = Files.newByteChannel(tis.getPath())) {
+ return movieBox(new ChannelBoxes(channel));
Review Comment:
`movieBox(TikaInputStream)` currently forces materialization to a file via `tis.getPath()` and `Files.newByteChannel(...)`. TikaInputStream already provides `getSeekableByteChannel()`, which can serve in-memory content without forcing it to disk and is the common pattern elsewhere in the codebase; using it here avoids unnecessary spooling/copies for byte[]/in-memory sources while still supporting random access.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-3646: Type a plain MP4 by its tracks, not by its brand [tika]
Posted by "dschmidt (via GitHub)" <gi...@apache.org>.
dschmidt commented on PR #3114:
URL: https://github.com/apache/tika/pull/3114#issuecomment-5591494680
I guess we can. I'll come back to it, if I need it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-3646: Type a plain MP4 by its tracks, not by its brand [tika]
Posted by "dschmidt (via GitHub)" <gi...@apache.org>.
dschmidt commented on PR #3114:
URL: https://github.com/apache/tika/pull/3114#issuecomment-5501558113
Honestly, having sat with this for a bit: I am not sure any more that it is worth it.
I built it for #3115, where the video trailing a motion photo has to be typed before it is emitted. It turns out not to buy anything there, because the embedded parse runs `MP4Parser`, which sets the type correctly anyway.
That is the general picture, too. `MP4Parser` already does what this detector does: `isAudioOnly` marks an audio-only file as `audio/mp4`, and the compatible brand list gets `testMP4Video.mp4` to `video/mp4`, which `MP4ParserTest` asserts today. Both files attached to TIKA-3646 are already typed correctly after a parse. What is left over is detect-only callers, and I do not have a real use case for that beyond tidiness.
So folding it into the parser would mostly mean writing what the parser already does. As I see it:
1. Close this, and answer TIKA-3646 with "the parse gets it right, detection alone does not".
2. Keep the detector, but opt-in only (`spi = false`, the way `Pkcs7Detector` is), for callers that need the type without a parse.
3. Keep only the `Mp4Boxes` extraction, which shares the box primitives instead of leaving a third copy of a box walk around, and drop the detector.
I lean towards 1, or 3 if the shared primitives are worth keeping on their own. Your call.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org