Extracting GPS data from INSV file

Started by SM26, February 13, 2019, 09:41:18 AM

Previous topic - Next topic

Phil Harvey

Yes.  Modify the gps.fmt file to write anything you want.  You may have to consult the GPX specification to see how to format this properly.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

SM26

Sorry, But I don't quite follow

Like we said earlier, record 0x300 seems like accelerometer information.

When I look at the GoPro and Ricoh tag pages, I see they have accelerometer data.
What and how should I alter the FMT to show all of the data?

I've made small changes to the FMT file, but now it shows up blank...

#------------------------------------------------------------------------------
# File:         gpx.fmt
#
# Description:  Example ExifTool print format file for generating GPX track log
#
# Usage:        exiftool -p gpx.fmt FILE [...] > out.gpx
#
# Requires:     ExifTool version 10.49 or later
#
# Revisions:    2010/02/05 - P. Harvey created
#               2018/01/03 - PH Added IF to be sure position exists
#               2018/01/06 - PH Use DateFmt function instead of -d option
#
# Notes:     1) Input files must contain GPSLatitude and GPSLongitude.
#            2) Add the -ee option to extract the full track from video files.
#            3) The -fileOrder option may be used to control the order of the
#               generated track points when processing multiple files.
#------------------------------------------------------------------------------
#[HEAD]<?xml version="1.0" encoding="utf-8"?>
#[HEAD]<gpx version="1.0"
#[HEAD] creator="ExifTool $ExifToolVersion"
#[HEAD] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
#[HEAD] xmlns="http://www.topografix.com/GPX/1/0"
#[HEAD] xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
#[HEAD]<trk>
#[HEAD]<number>1</number>
#[HEAD]<trkseg>
#[IF]  $gpslatitude $gpslongitude
#[IF]  $accelerometer
#[BODY]<trkpt lat="$gpslatitude#" lon="$gpslongitude#">
#[BODY]  <ele>$gpsaltitude#</ele>
#[BODY]  <acc>$accelerometer#</acc>
#[BODY]  <time>${gpsdatetime#;DateFmt("%Y-%m-%dT%H:%M:%SZ")}</time>
#[BODY]</trkpt>
#[TAIL]</trkseg>
#[TAIL]</trk>
#[TAIL]</gpx>

From the GoPro page, I think that the following tags are interesting:
ACCL, GLPI, GPRI, GPS5, GYRO, MAGN
And from the Ricoh page, I think that the following tags are interesting:
Ricoh ThetaSubdir Tags ->0x0003 Accelerometer, 0x0004 Compass


Phil Harvey

The main problem with what you are trying to do is that the accelerometer readings aren't timed the same as the GPS, so they can't be combined like this.  They are based on a TimeCode, while the GPS readings are based on GPSDateTime.  You can add the GPSSpeed and GPSTrack to the GPS records in the GPX file, but it would take some work to be able to relate the TimeCode values to a clock time so you could add in the accelerometer information.  Frankly, I don't know how to do this.  Use this command to see all of the available information:

exiftool -ee -G3 FILE

In this output, each document number represents the information extracted for a specific SampleTime, TimeCode or GPSDateTime.  Note that GPS is sampled at a much different rate than the accelerometer readings.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

SM26

Ok, I think I have an idea,

Based on Garmin data that I found (and let's hope that Insta360 log data the same way as Garmin)
each GPS record correspond with 10 Accelerometer and Angular Velocity docs. (for now let's leave the offset out of this)
https://www8.garmin.com/xmlschemas/AccelerationExtensionv1.xsd
Let's hope that I what the XYZ value match correspondingly

So, for file 052, the EOF should look like this:
<trkpt lat="32.08802777777778" lon="34.85615555555556">
        <ele>61.5087</ele>
        <time>2019-02-19T14:29:02Z</time>
        <extensions>
          <acc:AccelerationExtension xmlns:acc="http://www.garmin.com/xmlschemas/AccelerationExtension/v1">
            <acc:accel x="0.065185546875" y="-0.977294921875" z="0.24462890625" />
            <acc:accel x="0.06591796875" y="-0.97607421875" z="0.242431640625" />
            <acc:accel x="0.064453125" y="-0.975830078125" z="0.23974609375" />
            <acc:accel x="0.064453125" y="-0.975341796875" z="0.24267578125" />
            <acc:accel x="0.0654296875" y="-0.979248046875" z="0.2421875" />
            <acc:accel x="0.061279296875" y="-0.977294921875" z="0.239501953125" />
            <acc:accel x="0.065185546875" y="-0.977294921875" z="0.24462890625" />
            <acc:accel x="0.0625" y="-0.9765625" z="0.24267578125" />
            <acc:accel x="0.0625" y="-0.97265625" z="0.239501953125" />
            <acc:accel x="0.066162109375" y="-0.974609375" z="0.240478515625" />
          </acc:AccelerationExtension>
          <Gyro:Angular Velocity>
            <acc:accel x="0.00639158661619017" y="0.0149137021044437" z="0.00852211548825355" />
            <acc:accel x="0.00852211548825355" y="0.0149137021044437" z="0.00852211548825355" />
            <acc:accel x="0.00639158661619017" y="0.0149137021044437" z="0.00852211548825355" />
            <acc:accel x="0.00852211548825355" y="0.0149137021044437" z="0.00958737992428525" />
            <acc:accel x="0.00852211548825355" y="0.0159789665404754" z="0.0106526443603169" />
            <acc:accel x="0.00852211548825355" y="0.013848437668412" z="0.00852211548825355" />
            <acc:accel x="0.00639158661619017" y="0.013848437668412" z="0.00745685105222186" />
            <acc:accel x="0.00639158661619017" y="0.013848437668412" z="0.00852211548825355" />
            <acc:accel x="0.00639158661619017" y="0.0149137021044437" z="0.00852211548825355" />
            <acc:accel x="0.00639158661619017" y="0.0127831732323803" z="0.00958737992428525" />
          </Gyro:Angular Velocity>
        </extensions>
      </trkpt>


Any change to make something like this?

Phil Harvey

I still don't know how to relate the accelerometer TimeCode values to the GPSDateTime.  You can't just assume that the first TimeCode corresponds with the first GPSDateTime because.

1. It is quite likely that the GPS system takes a while to acquire a lock, and hence the first reading may be a while after the start of the video.

2. You would likely be wrong by half of the GPS sampling period on average even if they did start at the same time.

But even if you can relate these times, constructing the combined GPX output file is currently beyond the capabilities of ExifTool, and would require some dedicated scripting to achieve.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

SM26

Ok,
I'll spend some more time with it, maybe I'll manage to learn something new.

Last question (hopefully)
I have a file that is 18 GB (19,220,410,368 bytes to be exact)

When I run Exiftool -ee -p gpx2.fmt Vid_long.insv > Vid_Long.gpx
I get:
Out of memory!

for the record, my config file has "LargeFileSupport => 1" in it.

Phil Harvey

Unfortunately there is a limit on the amount of memory that a Windows command-line process may allocate.  I don't know why this limit is imposed, but it is around 300 MB or so.  Mac and Linux have no such limitation.  I don't know any way around this on Windows.  Processing very large video files with the -ee option does use a fair bit of memory.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

SM26

oh, Ok.
Thanks!

good think I have a linux laptop laying around

SM26

So, just to sum it up
Phil, you have helped me a lot.

Insta360 replied to my email, and they said that they are not going to help understand the Gyro data.

But nevertheless, for your time and effort
as a token of my appreciation, let me buy you a pint!

PayPal's Transaction ID: 3RE879167D940642R

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yamuna

Hello Everyone,

I am trying to use Exiftool 11.66 for extracting GPS data from .insv file taken using (Insta 360 ONEX camera).

The command I used:
exiftool -ee -p "GPS $gpslatitude $gpslongitude" -n "C:\VID_003.insv" > VID_003.txt

I am getting results. Latitude looks right however Longitude shows incorrect value.

GPS 40.74103544 -5450.57354413288

Appreciated your help.

Thanks,
Yamuna.

Phil Harvey

Hi Yamuna,

It could be that the format of this metadata is somehow different than my current INSV sample.

Could you possibly send me a (hopefully small) INSV file with GPS information?  I'll see if I can figure out what is going on.  My email is philharvey66 at gmail.com

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yamuna

Hi Phil,

Thanks for the swift response. sent you the sample insv file.

Yamuna.

Phil Harvey

Hi Yamuna,

I got the sample, thanks.

This was a bug in ExifTool that I have fixed in version 11.67 (just released).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yamuna