ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: trymeout on April 30, 2021, 05:00:05 PM

Title: Remove GPS altitude and altitude ref from MP4 files
Post by: trymeout on April 30, 2021, 05:00:05 PM
Is there a command I can use to remove the GPS altitude and GPS altitude ref from MP4 files. I tried this but it does not work with some other spelling :(

exiftool -gps:altitude= video.mp4
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: StarGeek on April 30, 2021, 05:37:53 PM
FAQ #3 (https://exiftool.org/faq.html#Q3) 
If you use the command in that FAQ, you'll see that the GPS data is all combined in one tag, GPSCoordinates, which is a Quicktime tag.  The Composite group that appears at the end are tags that exiftool creates out of other tags in the file.  This is useful in your case because you'll need them to re-write the GPSCoordinates tag.

Try
exiftool "-GPSCoordinates<$GPSLatitude , $GPSLongitude" video.mp4
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: trymeout on April 30, 2021, 05:49:46 PM
When I run this command it will not update the file. I tried this on the ShortVideo.mp4 I shared in my other post.

$exiftool "-GPSCoordinates<$GPSLatitude , $GPSLongitude" ShortVideo.mp4
Warning: No writable tags set from ShortVideo.mp4
Warning: Invalid tag name ', ' - ShortVideo.mp4
    0 image files updated
    1 image files unchanged
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: StarGeek on April 30, 2021, 06:14:02 PM
Sorry, forgot you weren't on Windows.  The double quotes means that your shell interprets the dollar signs as the start of a shell variable.  Swap any single/double quotes.
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: trymeout on April 30, 2021, 06:57:30 PM
Is there a command that will work for on Windows and Linux that is the same in spelling? I tried this by swapping out the double quotes to single quotes and I still get an error.

exiftool '-GPSCoordinates<$GPSLatitude , $GPSLongitude' video.mp4
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: StarGeek on April 30, 2021, 07:11:40 PM
Windows CMD will use
exiftool "-GPSCoordinates<$GPSLatitude, $GPSLongitude" video.mp4

Mac/Linux and maybe Powershell will use
exiftool '-GPSCoordinates<$GPSLatitude, $GPSLongitude' video.mp4

Each shell works in different ways, so you can't have one command for all when quotes are involved...

Well, you can if you move the commands to a args file.  See -@ (Argfile) option (https://exiftool.org/exiftool_pod.html#ARGFILE) and github repository (https://github.com/exiftool/exiftool/tree/master/arg_files) for example args files.
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: trymeout on April 30, 2021, 08:03:04 PM
This command did execute but it did not remove the Altitude from the video GPS metadata

exiftool '-GPSCoordinates<$GPSLatitude, $GPSLongitude' ShortVideo.mp4

Here is the video I am trying to do this to
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: StarGeek on April 30, 2021, 08:59:54 PM
Ah, it's located in UserData:LocationInformation.  I haven't see that before, though obviously Phil has as it's a source tag on the Composite tag page (https://exiftool.org/TagNames/Composite.html).

Try this
exiftool '-LocationInformation<${LocationInformation;s/Alt=-?\d+\.\d+/Alt=/}' ShortVideo.mp4

This performs a RegEx substitution on LocationInformation to remove the altitude data.  But if you have another program that reads this data, it may not like the change, i.e. the altitude might be a requirement.  Test it to be sure.
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: trymeout on April 30, 2021, 09:53:44 PM
This is my output in the terminal. Sadly this did not work.

$ exiftool '-LocationInformation<${LocationInformation;s/Alt=-?\d+\.\d+/Alt=/}' ShortVideo.mp4
Warning: No writable tags set from ShortVideo.mp4
    0 image files updated
    1 image files unchanged
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: StarGeek on May 01, 2021, 01:16:53 AM
Looks like the ability to write that tag was just added (https://exiftool.org/forum/index.php?topic=12393.msg67137#msg67137) less than a week ago.  But it appears that a value for altitude is required, as exiftool won't write it without one.
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: trymeout on May 01, 2021, 06:05:31 PM
On your reddit post not too long ago you explained how this command can set or change the latitude and longitude GPS coordinates of a video. I am using ExifTools 11.88 since that is the latest version available on my Linux distro and when I use this on a video that does not have any GPS coordinates data, it will add the GPS coordinates but without any altitude metadata when I use exiftool video.mp4 command after to see the GPS metadata.

exiftool -gpscoordinates="40.6892, -74.0445" "video.mp4"

Does the latest version of exiftools now always adds an altitude of 0 when using this command above now since altitude is not set in the command?
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: StarGeek on May 01, 2021, 06:19:45 PM
That command will add the GPS coordinates without the altitude.  Altitude isn't required for that tag.  But if the LocationInformation tag exists, exiftool will pull the altitude from that tag and exiftool will write a 0 altitude when writing that tag.

Other programs might not read the LocationInformation and would probably just display data from the GPSCoordinates tag.

To update exiftool, all you need to do is download the main archive on the main page and copy that over the preexisting copy.  You just need to figure out where it currently exists.
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: trymeout on May 04, 2021, 12:04:09 AM
It will seems that this command...

exiftool -overwrite_original -gpscoordinates="40.6892, -74.0445" "video.mp4"



in the latest verion of exiftool will return this for GPS data in a MP4 file that does not have any GPS metadata prior to this command

User Data xyz                   : +40.6892-074.0445/



But this is the metadata it will add to the same file using exiftools 11.88.

GPS Coordinates                 : 40 deg 41' 21.12" N, 74 deg 2' 40.20" W

GPS Latitude                    : 40 deg 41' 21.12" N
GPS Longitude                   : 74 deg 2' 40.20" W
Rotation                        : 0
GPS Position                    : 40 deg 41' 21.12" N, 74 deg 2' 40.20" W



From now on, will exiftool only write "User Data xyz" when using this command and not add an altitude to the MP4 file? If this is the case this will seem fine with me since it does embed the lat and long into the MP4 which is all I want.
Title: Re: Remove GPS altitude and altitude ref from MP4 files
Post by: Phil Harvey on May 05, 2021, 07:25:06 PM
I get this:

> Image-ExifTool-12.25/exiftool a.mp4 b.mp4 -G1 "-gps*"
======== a.mp4
======== b.mp4
    2 image files read
> Image-ExifTool-12.25/exiftool a.mp4 -gpscoordinates="40.6892, -74.0445"
    1 image files updated
> Image-ExifTool-11.88/exiftool b.mp4 -gpscoordinates="40.6892, -74.0445"
    1 image files updated
> Image-ExifTool-12.25/exiftool a.mp4 b.mp4 -G1 "-gps*"              ======== a.mp4
[Keys]          GPS Coordinates                 : 40.689200 N, 74.044500 W
[Composite]     GPS Latitude                    : 40.689200 N
[Composite]     GPS Longitude                   : 74.044500 W
[Composite]     GPS Position                    : 40.689200 N, 74.044500 W
======== b.mp4
[Keys]          GPS Coordinates                 : 40.689200 N, 74.044500 W
[Composite]     GPS Latitude                    : 40.689200 N
[Composite]     GPS Longitude                   : 74.044500 W
[Composite]     GPS Position                    : 40.689200 N, 74.044500 W
    2 image files read


- Phil