file does not save sometimes. can someone please tell me the reason for it.
pipe = Popen(f'exiftool.exe -p "lib/ExifTool/gpx.fmt" -S -ext mov -ee "{video_file}" >> "temp/gpx.xml"', shell=True, stdout=PIPE)
file does not save sometimes. can someone please tell me the reason for it.
pipe = Popen(f'exiftool.exe -p "lib/ExifTool/gpx.fmt" -S -ext mov -ee "{video_file}" >> "temp/gpx.xml"', shell=True, stdout=PIPE)
The warnings you received (and the failure to write) are caused by one of the following:
gpx.fmt
), that do not exist.Writing the output to files using Python instead may help you work around the the first issue. Using -f
in your ExifTool command will set the value equal to a dash '-' if a tag you specified in your print format file wasn't found. Alternatively you could use an if-statement in your print format file or -m
in your command to avoid warnings.
Here is an example where Python is used to capture the ExifTool output and write it to an XML file:
import shlex, subprocess
format_filepath = "Path/To/gpx.fmt"
input_dirpath = "Path/To/Dir"
output_filepath = "Path/To/out.xml"
# I have added the path to exiftool.exe to my PS env so I can just pass exiftool
arg_str = f"exiftool -p {format_filepath} -S -ee -f -ext mov {input_dirpath}"
args = shlex.split(arg_str)
# args=['exiftool', '-p', 'Path/To/gpx.fmt', '-S', '-ee', '-f', '-ext', 'mov', 'Path/To/Dir']
# shell=True is not needed here because ExifTool is an executable
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# You may use code=proc.wait() here, where code=0 means the proccess executed successfully
stdout,stderr = proc.communicate()
# communicate() returns bytes by default
with open(output_filepath, 'wb') as fout:
fout.write(stdout)
Print format file gpx.fmt
:
#[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>
#[BODY]<trkpt lat="$gpslatitude#" lon="$gpslongitude#">
# Without adding -f or -m to cmd, the below three elements will give Warnings
#[BODY] <ele>$Doc29:gpsaltitude#</ele>
#[BODY] <ele>$Doc30:gpsaltitude#</ele>
#[BODY] <ele>$Doc39:gpsaltitude#</ele>
# or try the following element instead:
#[BODY] <ele>$gpsaltitude#</ele>
#[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>