-
-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distinguish UTC vs local video takestamps #680
Conversation
@@ -237,7 +272,7 @@ public function extract(string $filename, string $type): array | |||
$metadata['position'] = implode(', ', $fields); | |||
} | |||
|
|||
if (strpos($type, 'video') !== 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure about that one ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeap I'm reading I'm reading. :) I just quickly commented. :p
@@ -82,7 +82,7 @@ public function extract(string $filename, string $type): array | |||
$is_raw = true; | |||
} | |||
|
|||
if (strpos($type, 'video') !== 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure about that one ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure... It's because of those crazy MPG files being identified by mime_content_type
as image/x-tga
. So I added image/x-tga
to $validVideoTypes
, fixed file_type
to do what it was actually supposed to (so that it actually returns 'video'
for video files), and then replaced all these ad-hoc tests by the more robust checks based on the value returned by file_type
.
Handle MPG videos correctly. Handle WMV videos with Exiftool extractor correctly. Fix the broken PhotoFunctions::file_type method which would not distinguish between images and videos. Don't extract a video frame if FFmpeg is disabled in the config.
4fdc87f
to
4395b79
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Fixes #675.
This adds a heuristic to determine whether the takestamp embedded in a video file is in UTC or in local time. The heuristic is based on the filename extension. There is a new config variable,
local_takestamp_video_formats
, that provides a list the extensions for files that should be treated as having a takestamp in the local time zone. It defaults to AVI and MOV, as those are the two most commonly used in digital cameras, which typically use the local time zone. For files that don't match (such as MP4 files from Android phones) the takestamp is considered to be in UTC and is converted at import time to the local time zone of the server.While working on this I noticed several bugs that this PR also fixes. In particular:
MPG files were treated as image files because at least on my system that's what the MIME says (
image/x-tga
)?!file_type
method inPhotoFunctions
was fundamentally broken; it would returnphoto
for video files. Fixing its twisted logic required a complete refactoring.With that fixed, I was able to replace all the ad-hoc tests for video files based on MIME, which didn't work for MPG files (see above).
WMV videos misbehaved when using the Exiftool metadata extractor because of conflicting MIME data (Exiftool identifies them as
video/x-ms-wmv
). There were many other issues when using Exiftool instead of FFmpeg for video files' metadata, which were addressed in Video fixes php-exif#22 (now merged).If FFmpeg is disabled in the config, we shouldn't try to use it to for anything, including extracting a video frame for the thumb. I fixed that particular use case but it appears that there may be more left in the new live photos support? I'm not familiar with that feature so I didn't touch it. @tmp-hallenser?