Skip to content

Commit

Permalink
Ensure a local timestamp for mov videos (#1387)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil4 authored Jul 2, 2022
1 parent 0ad811c commit 35701b1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/Metadata/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ public static function createFromFile(NativeLocalFile $file): self
//
// Here, we rely here on a simple filetype-based heuristics and,
// for a timestamp we suspect to be in UTC, we convert it to the
// application's default timezone.
// application's default timezone. For a timestamp we suspect to
// be local, we ensure that the extractor didn't erroneously mark
// it as UTC.
// All other timestamps are not altered, but used "as is":
//
// i) Either the meta-data extractor was able to properly
Expand Down Expand Up @@ -366,6 +368,22 @@ public static function createFromFile(NativeLocalFile $file): self
// The only known example are the mov files from Apple
// devices; the time zone will be formatted as "+01:00"
// so neither of the two conditions above should trigger.
} elseif ($taken_at->getTimezone()->getName() === 'Z') {
// This is a video format where we expect the takestamp
// to be provided in local time but the timezone is
// (erroneuously) set to Zulu (UTC). This will trigger,
// e.g., for mov files with the FFprobe extractor.
// We recreate the recording time as a timestamp in the
// application's default timezone.
// Note: This assumes that the application's default
// timezone is the same as the timezone of the
// location where the video has been recorded and that
// the beholder (of the video) expects to observe
// that timezone.
$taken_at = new Carbon(
$taken_at->format('Y-m-d H:i:s'),
new \DateTimeZone(date_default_timezone_get())
);
}
}
$metadata->taken_at = $taken_at;
Expand Down

0 comments on commit 35701b1

Please sign in to comment.