Extracting GPS data from INSV file

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

Previous topic - Next topic

paluan01

Hu,
this si my .fmt with the last indication

#[BODY]   <time>${gpsdatetime#;DateFmt("%Y-%m-%dT%H:%M:%SZ")}</time>


hereby all the .fmt file


#------------------------------------------------------------------------------
# File:         gpx.fmt
#
# Description:  Example ExifTool print format file to generate a GPX track log
#
# Usage:        exiftool -p gpx.fmt -ee3 FILE [...] > out.gpx
#
# Requires:     ExifTool version 10.49 or later
#
# Revisions:    2010/02/05 - P. Harvey created
#               2018/01/04 - PH Added IF to be sure position exists
#               2018/01/06 - PH Use DateFmt function instead of -d option
#               2019/10/24 - PH Preserve sub-seconds in GPSDateTime value
#
# Notes:     1) Input file(s) must contain GPSLatitude and GPSLongitude.
#            2) The -ee option is 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
#[BODY]<trkpt lat="$gpslatitude#" lon="$gpslongitude#">
#[BODY]  <ele>$gpsaltitude#</ele>
#[BODY]   <time>${gpsdatetime#;DateFmt("%Y-%m-%dT%H:%M:%SZ")}</time>
#[BODY]</trkpt>
#[TAIL]</trkseg>
#[TAIL]</trk>
#[TAIL]</gpx>


Phil Harvey

Unfortunately you pasted your fmt file instead of attaching it, so I can't reproduce what you are seeing.  But I'm sure the problem is that your .fmt file is not plain ASCII text.  From the corrupted output my guess is that you saved it as RTF.  Try saving it as plain ASCII text.

- 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 ($).

martinr36

Hi, I'm trying to do this but  aren't having a lot o9f success.
Ive downloaded and installed the 64 bit version from here https://oliverbetz.de/pages/Artikel/ExifTool-for-Windows and I've tried using the command exiftool -p gpx.fmt -ee3 H:\onex2\VID_20210813_155708_00_017.insv > out.gpx which produced the following results

Warning: End of processing at large atom (LargeFileSupport not enabled) - H:/onex2/VID_20210813_155708_00_017.insv
Warning: [Minor] Insta360 accelerometer data is huge. Processing only the first 20000 records - H:/onex2/VID_20210813_155708_00_017.insv

So after a bit of reading through here i tried exiftool -api LargeFileSupport -p gpx.fmt -ee3 H:\onex2\VID_20210813_155708_00_017.insv > out.gpx which produced this

Warning: Truncated '\x00\x00\x00\x00' data - H:/onex2/VID_20210813_155708_00_017.insv
Warning: [Minor] Insta360 accelerometer data is huge. Processing only the first 20000 records - H:/onex2/VID_20210813_155708_00_017.insv

I did find a file called gpx.out, and when i looked at it in notepad this is what i found  (see Attachment)

Can someone please point me in the right direction




StarGeek

As you figured out, the first error indicated the need to add the -api LargeFileSupport option.

Looking at your GPX file shows a second problem.  The output is nothing but "gpx.fmt" over and over.  This indicates that you do not have the GPX.fmt file.  Download the GPX.fmt file from Github and place it in current directory that you're running exiftool from or give the full path the the fmt file after the -p (-printFormat) option, e.g. -p C:\path\to\GPX.fmt

Finally, because of the "accelerometer data is huge" warning, the output may not show all the GPS coordinates.  I'm not sure.  But I think you can add the -m (-ignoreMinorErrors) option to tell exiftool to process all the entries, though because of the size, it might take a long time.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

martinr36

Quote from: StarGeek on August 20, 2021, 11:36:15 AM
As you figured out, the first error indicated the need to add the -api LargeFileSupport option.

Looking at your GPX file shows a second problem.  The output is nothing but "gpx.fmt" over and over.  This indicates that you do not have the GPX.fmt file.  Download the GPX.fmt file from Github and place it in current directory that you're running exiftool from or give the full path the the fmt file after the -p (-printFormat) option, e.g. -p C:\path\to\GPX.fmt

Finally, because of the "accelerometer data is huge" warning, the output may not show all the GPS coordinates.  I'm not sure.  But I think you can add the -m (-ignoreMinorErrors) option to tell exiftool to process all the entries, though because of the size, it might take a long time.

Many thanks for this, that did the trick

st_lupo

Sorry to resurrect a zombie but this thread has helped me immensly in extracting the GPS data from an insv file from an Insta 360 One RS.  Just one question though, does anybody have any ideas on synchronizing the GPS data (that is sequenced by gps date-time) with a corresponding frame in the video stream?   Thanks!

Phil Harvey

Knowing the time at the start of the video, and the video frame rate, you should be able to determine the time for each frame within a second, and use this to match up with the GPS track.  You will probably have to get creative to get sub-second accuracy.

- 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 ($).

st_lupo

Hi Phil, thanks for the reply!  I think I finally have this figured out (I just needed to sleep on it), and have been approaching this the wrong way.  I was originally thinking to use the GPS data embedded in the Insta360 video (which depending on the source for the GPS data, has varying update rates).  Now I guess the easiest way is to record the GPS data on one of my GPS devices (and export that to gpx).  Then in my video I make sure I initially record the GPS time displayed on the GPS device (and capture a change to the seconds) so I can get a hack to synchronize the video sample-time to the gps date-time.  Should be good to under a second?

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 ($).

kitarolivier

As perfect neewbie (first post  ;) ), i'm also resurrecting a zombie.

I'm posting here, because I could not find another place on the web where solutions are so close.

After reading, I still can't figure out how to sync GPS data and video.

I tried a different approach by using last GPS Date/Time minus movie duration.
I tried with one example and have strange results :
Last GPS Date/Time : 2023:04:05 07:17:52Z
Duration : 0:01:31
With the formula : 07:17:52 - 0:01:31 = 07:16:21

First GPS entry : 2023:04:05 07:15:42Z  (WTF ?!?!?)

Substracting firt GPS time from last GpsTime give a (gps) movie length of 0:02:10 !!

And all dates in main section are 2023:04:05 07:16:12

When opening file in Studio, it says no gps data from 00:00 to 00:03.

Can anyone help me ?

Thank you.

Phil Harvey

I think you need to shoot a few test videos with the camera pointed at a GPS-synced clock.

- 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 ($).

StarGeek

Quote from: kitarolivier on April 05, 2023, 09:22:24 AMWhen opening file in Studio, it says no gps data from 00:00 to 00:03.

Can anyone help me ?

If there's no data in the first few seconds, and exiftool agrees with that, then whatever recorded the file had a delay of some sort in recording the GPS data.  Not much can be done about that.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

kitarolivier

Quote from: Phil Harvey on April 05, 2023, 10:04:46 AMI think you need to shoot a few test videos with the camera pointed at a GPS-synced clock.

- Phil

Thank you for your answer.

That's a good idea. But it doesn't tell me why the GPS duration is longer than the video file.

kitarolivier

Quote from: StarGeek on April 05, 2023, 10:07:37 AM
Quote from: kitarolivier on April 05, 2023, 09:22:24 AMWhen opening file in Studio, it says no gps data from 00:00 to 00:03.

Can anyone help me ?

If there's no data in the first few seconds, and exiftool agrees with that, then whatever recorded the file had a delay of some sort in recording the GPS data.  Not much can be done about that.

Of course, non recorded GPS are lost. But how Insta360 studio computes the time between the video start time and the gps start time ?