polyvertex / fitdecode

A FIT file parsing and decoding library written in Python3
MIT License
158 stars 34 forks source link

Decoding VIRB camera .fit files #6

Closed GGDRriedel closed 4 years ago

GGDRriedel commented 4 years ago

I am trying to decode VIRB camera data. So far the FitdataMessage Types I could get are

'accelerometer_data', 'activity', 'barometer_data', 'camera_event',
       'device_info', 'event', 'file_creator', 'file_id', 'gps_metadata',
       'gyroscope_data', 'lap', 'magnetometer_data',
       'one_d_sensor_calibration', 'record', 'session',
       'three_d_sensor_calibration', 'timestamp_correlation',
       'unknown_104', 'unknown_219', 'unknown_22'

Now I need to correlate the gps_metadata with the video files frames. Since I can't find any info I printed the camera_event.

This yields something like

timestamp: 5098
camera_file_uuid: VIRBactioncameraULTRA30_Video_1920_1080_50.0000_3957746800_3836806b_1_196_2019-11-19-10-45-01.fit
timestamp_ms: 396
camera_event_type: 6
camera_orientation: 0

Since the uuid is a bit cryptic I guess that the timestamp (goes from 686 to 5098) is the stamp in some internal timestamp counter.

However, I can't get hold of that. The FitDataMessage

timestamp_correlation

only contains

timestamp: 943091155
system_timestamp: 55
local_timestamp: 943094755
timestamp_ms: 0
system_timestamp_ms: 180

This doesn't seem like a timestamp that I can convert easily.

EDIT:

Turns out Garmin is very special: http://www.nlvocables.com/blog/?p=969

Add 631065600

But now since i have my data and times, I need to look for the data that defines the videos taken with the Garmin cam. Does anybody have an idea?

polyvertex commented 4 years ago

How do you create your fitdecode.FitReader object? It looks like you do not use any processor which, by default, takes care of converting FIT date_time fields to Python datetime.datetime objects automatically.

I need to look for the data that defines the videos taken with the Garmin cam

I do not own any VIRB device but it certainly look like the camera_event message might be what you need. Hopefully it is enough without having to reverse the meaning of the other unknown_ messages you get.

GGDRriedel commented 4 years ago

I used your example so I use

  with fitdecode.FitReader(src_file) as fit:

My problem is that the file does not seem to include any sort of metadata about the related video whatsoever. I listed every possible parameter within the frames, nothing. The camera_event does contain data about creation time and stuff like that, but nothing directly linkable to the according video. I can get a list of start/end dates. After that I have to trust the folder I am in, count the videos(that are numbered) and find some way to compare creation timing(which falls on its face as soon as the videos are copied/restored in certain conditions).

It's a really unellegant solution prone to endless errors. Thus I hoped you or someone else knew how Garmin keeps track of which video is which in the .fit files.

polyvertex commented 4 years ago

Sorry I cannot help with that. Closing this due to inactivity and because it does not seem related to fitdecode itself.

robertmoga commented 2 years ago

The video metadata embeds the uuid you are extracting from the camera event. A fit file can hold data for multiple videos. A project that is matching a target video with the right fit file is this one : Fit Video2Fit. Hope it helps.