Hier die vollständige Anleitung, wie man aus einer Garmin Dash Cam MP4 Datei GPX Daten mittels ExifTool für RC extrahiert.
Es wird eine Datei benötigt, welche das zu schreibende Format festlegt (gpx.fmt):
Code:
#------------------------------------------------------------------------------
# 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
# 2023/10/14 - CD changed to Garmin DashCam 67W available data and
# correction of gxp version to 1.0
#
# Notes: 1) Input file(s) must contain GPSLatitude and GPSLongitude.
# 2) The -ee3 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.
# 4) Coordinates are written at full resolution. To change this,
# remove the "#" from the GPSLatitude/Longitude tag names below
# and use the -c option to set the desired precision.
#------------------------------------------------------------------------------
#[HEAD]<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
#[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] <time>${gpsdatetime#;my ($ss)=/\.\d+/g;DateFmt("%Y-%m-%dT%H:%M:%SZ");s/Z/${ss}Z/ if $ss}</time>
#[BODY]</trkpt>
#[TAIL]</trkseg>
#[TAIL]</trk>
#[TAIL]</gpx>
Weiterhin wird eine Configdatei benötigt, welche die Zeitdaten korrekt darstellt (gpsdatetime.config):
Code:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
GPSDateTime => {
Description => 'GPS Date/Time',
Groups => { 2 => 'Time' },
SubDoc => 1,
Require => {
0 => 'Main:CreateDate',
1 => 'SampleTime',
},
ValueConv => q{
my $time = $val[0];
my $diff = $val[1];
# handle time zone and shift to UTC
if ($time =~ s/([-+])(\d{1,2}):?(\d{2})$//) {
my $secs = (($2 * 60) + $3) * 60;
$secs *= -1 if $1 eq '+';
$diff += $secs;
} elsif ($time !~ s/Z$//) {
# shift from local time
$diff += GetUnixTime($time, 1) - GetUnixTime($time);
}
my $sign = ($diff =~ s/^-// ? '-' : '');
$time .= '.000'; # add decimal seconds
ShiftTime($time, "${sign}0:0:$diff");
return $time . 'Z';
},
PrintConv => '$self->ConvertDateTime($val)',
},
},
);
Dann kann man mit einer Batchdatei (im Command Window) wie folgt eine GPX Datei erzeugen:
Code:
.\exiftool.exe -config gpsdatetime.config -p gpx.fmt -ee a.MP4 > out.gpx
Alle drei Dateien müssen natürlich im gleichen Verzeichnis stehen, wie die MP4 Datei oder alternativ müssen Pfade ergänzt werden.
Wer CSV bevorzugt:
Die Datei zur Erzeugung der CSV Variante sieht wie folgt aus (csv.fmt):
Code:
#------------------------------------------------------------------------------
# File: csv.fmt
#
# Description: Example ExifTool print format file to generate a CSV track log
#
# Usage: exiftool -p gpx.fmt -ee3 FILE [...] > out.gpx
#
# Requires: ExifTool version 10.49 or later
#
# Revisions: 2023/10/13 - CD
#
# Notes: 1) Input file(s) must contain GPSLatitude and GPSLongitude.
# 2) The -ee3 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.
# 4) Coordinates are written at full resolution. To change this,
# remove the "#" from the GPSLatitude/Longitude tag names below
# and use the -c option to set the desired precision.
# usage with windows power shell: .\exiftool.exe -config gpsdatetime.config -p csv.fmt -ee a.MP4 | out-file "out.csv" -encoding ascii
# command window or batch file: .\exiftool.exe -config gpsdatetime.config -p csv.fmt -ee a.MP4 > out2.csv
#-----------------------------------------------------------------------------
#[HEAD]Latitude,Longitude,Timestamp
#[IF] $gpslatitude $gpslongitude
#[BODY]$gpslatitude#,$gpslongitude#,${gpsdatetime#;my ($ss)=/\.\d+/g;DateFmt("%Y-%m-%dT%H:%M:%SZ");s/Z/${ss}Z/ if $ss}
Die config Datei ist identisch zu oben und die batch Datei muss minimal angepasst werden:
Code:
.\exiftool.exe -config gpsdatetime.config -p csv.fmt -ee a.MP4 > out.csv
Gruß
Christian