Code Monkey home page Code Monkey logo

Comments (7)

fxstein avatar fxstein commented on July 29, 2024

Ok, after plenty of research and testing I have landed on the most common timeshifting problem and a partial solution for it.

GoPro cameras save video files with local times, while the QuickTime standard defined video time information in UTC. While staying within the GoPro camera itself and the Quik mobile app, that does not represent an issue as both treat it the same way. Unfortunately, all other platforms including GoPro Cloud, Apple Photos, and Google Photos treat the date/time information as UTC resulting in all videos being timeshifted once they leave the GoPro ecosystem.

exiftool provides a simple solution to timeshifting files and it should be able to incorporate that timeshift into the --process option without the need for an additional pass over the data.

For this to work we need the DST offset to be applied to the video date/time data of all the videos (not photos as they are correct). That offset could either come from the geonames lookup we perform after import (not perfect as we only do one lookup per day) or from the delta of the QuickTime Create Date and the first GPS Date of the file, since the GPS Date/Time is always in UTC. Alternatively, we could even consider using the first GPS Date/Time as is.

Here is an example of how to use exiftool to perform the timeshift:

exiftool -AllDates+=7 -quicktime:time:all+=7 -verbose -o P_20221004110648_GoPro_Hero10_2442_GX010328.mp4

As per this example, it will probably be a good idea to expand the file prefix from P_ for processed to PT_ for processed and timeshifted. Keeping the filename as is to preserve the local time the file was recorded in. This allows us to still find the originating imported file without additional logic at the library level.

from goprox.

fxstein avatar fxstein commented on July 29, 2024

Calculating the timeshift difference dynamically based on rounded hours between CreateDate and GPSDateTime:

exiftool -ee -d '%s' -p '${GPSDateTime;$_=int(($_-$self->GetValue("CreateDate"))/3600+0.5)}' P_20221004110648_GoPro_Hero10_2442_GX010328.mp4

from goprox.

fxstein avatar fxstein commented on July 29, 2024

The integrated version that calculates time shift and assigns it to all QuickTime dates that exist (but no more)

exiftool -wm w -ee -d '%s' '-quicktime:time:all<${GPSDateTime;$_=$self->GetValue("CreateDate")+int(($_-$self->GetValue("CreateDate"))/3600+0.5)*3600}' -o PT_20221004110648_GoPro_Hero10_2442_GX010328.mp4 P_20221004110648_GoPro_Hero10_2442_GX010328.mp4 -api TimeZone=GMT

The only thing left: replace rounding logic with one that works for negative offsets as well.

from goprox.

fxstein avatar fxstein commented on July 29, 2024

And this is the final exif logic with the expanded rounding logic that works for positive and negative offsets:

exiftool -wm w -ee -d '%s' '-quicktime:time:all<${GPSDateTime;$_=$self->GetValue("CreateDate")+int((($_-$self->GetValue("CreateDate"))/3600)+(($_-$self->GetValue("CreateDate"))/3600)/abs((($_-$self->GetValue("CreateDate"))/3600)*2 || 1))*3600}' -o PT_20221004110648_GoPro_Hero10_2442_GX010328.mp4 P_20221004110648_GoPro_Hero10_2442_GX010328.mp4 -api TimeZone=GMT

Next up is workflow integration. Will perform this time shift every time we process media for video files. Unfortunately due to the nature of the logic especially due to -wm w this cannot be combined with the current processing pass, but has to be executed as an additional pass over the data.

from goprox.

fxstein avatar fxstein commented on July 29, 2024

After extensive testing and repeat usage of the logic, it has become obvious that renaming time-shifted video media is not a good idea as repeat runs would hang themselves as exiftool cannot overwrite existing target files.

The new implementation keeps the original processed filename and simply shifts all Quicktime tags to UTC while preserving the filesystem modification date&time as well as the filename.

from goprox.

fxstein avatar fxstein commented on July 29, 2024

Need to investigate why the embedded timeshift within the process flow does not find matching files in some cases.

from goprox.

fxstein avatar fxstein commented on July 29, 2024

Turns out the default time format set via -d '%d' leads to a broken TimeFmt logic in the -if4 clause of the exiftool statement.

-if4 '${FileModifyDate;DateFmt("%s")} gt 1666957443'

breaks when combined into

-d '%s' -if4 '${FileModifyDate;DateFmt("%s")} gt 1666957443'

as a double conversion would take place. To fix any prior output of print format needs to be eliminated for this tag by adding a #

-d '%s' -if4 '${FileModifyDate#;DateFmt("%s")} gt 1666957443'

from goprox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.