Check major brand before checking compatible brands
@@ -86,7 +86,6 @@ public class MP4Parser extends AbstractParser {
/** TODO Replace this with a 2dp Duration Property Converter */
private static final DecimalFormat DURATION_FORMAT =
(DecimalFormat)NumberFormat.getNumberInstance(Locale.ROOT);
-
static {
DURATION_FORMAT.applyPattern("0.0#");
}
@@ -106,8 +105,8 @@ public class MP4Parser extends AbstractParser {
typesMap.put(MediaType.video("x-m4v"), Arrays.asList(
"M4V ", "M4VH", "M4VP"));
- typesMap.put(MediaType.video("quicktime"), Collections.<String>emptyList());
- typesMap.put(MediaType.application("mp4"), Collections.<String>emptyList());
+ typesMap.put(MediaType.video("quicktime"), Collections.emptyList());
+ typesMap.put(MediaType.application("mp4"), Collections.emptyList());
}
private static final Set<MediaType> SUPPORTED_TYPES =
@@ -139,11 +138,15 @@ public class MP4Parser extends AbstractParser {
MediaType type = MediaType.application("mp4");
final List<String> compatibleBrands = fileType.getCompatibleBrands();
for (Map.Entry<MediaType, List<String>> e : typesMap.entrySet()) {
- // Find entry which contains the file's major brand or any of the compatible brands
- if (e.getValue().contains(fileType.getMajorBrand())
- || !e.getValue().stream().filter(compatibleBrands::contains).collect(Collectors.toSet()).isEmpty()) {
+ if (e.getValue().contains(fileType.getMajorBrand())) {
type = e.getKey();
break;
+ } else {
+ // See if any of the compatible brands match
+ if (!e.getValue().stream().filter(compatibleBrands::contains).collect(Collectors.toSet()).isEmpty()) {
+ type = e.getKey();
+ break;
+ }
}
}
metadata.set(Metadata.CONTENT_TYPE, type.toString());
