Skip to content

Commit

Permalink
Merge pull request #589 from mveunen/bugfix/apple-metadata-sometimes-…
Browse files Browse the repository at this point in the history
…as-string

Sometimes the Apple metadata is stored as a String. This fix will pre…
  • Loading branch information
drewnoakes authored Sep 14, 2022
2 parents 3670a36 + 0b2d61b commit e9ff975
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Source/com/drew/metadata/apple/AppleRunTimeReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,23 @@ private static void processAppleRunTime(@NotNull final AppleRunTimeMakernoteDire

// https://developer.apple.com/documentation/coremedia/cmtime-u58

byte flags = (Byte)values.get("flags");

if ((flags & 0x1) == 0x1) {
directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeFlags, flags);
directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeEpoch, (Byte)values.get("epoch"));
directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeScale, (Long)values.get("timescale"));
directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeValue, (Long)values.get("value"));
Object flagsObject = values.get("flags");
if (flagsObject instanceof Byte) {
byte flags = (Byte) flagsObject;
if ((flags & 0x1) == 0x1) {
directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeFlags, flags);
directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeEpoch, (Byte) values.get("epoch"));
directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeScale, (Long) values.get("timescale"));
directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeValue, (Long) values.get("value"));
}
} else if (flagsObject instanceof String) {
byte flags = Byte.parseByte((String) flagsObject);
if ((flags & 0x1) == 0x1) {
directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeFlags, flags);
directory.setInt(AppleRunTimeMakernoteDirectory.CMTimeEpoch, Byte.parseByte((String) values.get("epoch")));
directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeScale, Long.parseLong((String) values.get("timescale")));
directory.setLong(AppleRunTimeMakernoteDirectory.CMTimeValue, Long.parseLong((String) values.get("value")));
}
}
}
}
Expand Down

0 comments on commit e9ff975

Please sign in to comment.