Copy GPS location metadata on .mov file from iphone

Started by schmurtz, February 23, 2014, 06:29:26 PM

Previous topic - Next topic

schmurtz

Hi,

To recover a lot of space on my iphone 4S I have re-encoded all my videos. But I want to keep all metadatas from my videos and specially GPS location.

I found exiftool which seems to be the ideal tool to do it.

So I've made a test :
I took a video file with GPS location metadata from my iphone and an other video file without GPS location (done with airplane mode). So, the 2 files have the same format because they came from the same device. But I can not copy the GPS location from a file to the other.

What I've done :
exiftool.exe File_With_GPS.MOV
[color=green]
ExifTool Version Number         : 9.53
File Name                       : File_With_GPS.MOV
Directory                       : .
File Size                       : 2.8 MB
File Modification Date/Time     : 2014:02:23 23:34:32+01:00
File Access Date/Time           : 2014:02:23 23:37:51+01:00
File Creation Date/Time         : 2014:02:23 23:37:51+01:00
File Permissions                : rw-rw-rw-
File Type                       : MOV
MIME Type                       : video/quicktime
Major Brand                     : Apple QuickTime (.MOV/QT)
Minor Version                   : 0.0.0
Compatible Brands               : qt
Movie Data Size                 : 2953390
Movie Data Offset               : 36
Movie Header Version            : 0
Create Date                     : 2014:02:23 22:34:30
Modify Date                     : 2014:02:23 22:34:31
Time Scale                      : 600
Duration                        : 1.04 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 2014:02:23 22:34:30
Track Modify Date               : 2014:02:23 22:34:31
Track ID                        : 1
Track Duration                  : 1.04 s
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 1920
Image Height                    : 1080
Clean Aperture Dimensions       : 1920x1080
Production Aperture Dimensions  : 1920x1080
Encoded Pixels Dimensions       : 1920x1080
Graphics Mode                   : ditherCopy
Op Color                        : 32768 32768 32768
Compressor ID                   : avc1
Source Image Width              : 1920
Source Image Height             : 1080
X Resolution                    : 72
Y Resolution                    : 72
Compressor Name                 : H.264
Bit Depth                       : 24
Video Frame Rate                : 24
Camera Identifier               : Back
Frame Readout Time              : 28512 microseconds
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2014:02:23 22:34:30
Media Modify Date               : 2014:02:23 22:34:31
Media Time Scale                : 44100
Media Duration                  : 1.07 s
Media Language Code             : und
Balance                         : 0
Handler Class                   : Data Handler
Handler Vendor ID               : Apple
Handler Description             : Core Media Data Handler
Audio Format                    : mp4a
Audio Channels                  : 1
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Purchase File Format            : mp4a
Model (fra)                     : iPhone 4S
Software Version (fra)          : 6.1.2
Create Date (fra)               : 2014:02:23 23:34:30+01:00
GPS Coordinates (fra)           : 53 deg 43' 1.92" N, 3 deg 4' 15.48" E, 27 m Above Sea Level
Make (fra)                      : Apple
Handler Type                    : Metadata Tags
Make (fra-FR)                   : Apple
Creation Date (fra-FR)          : 2014:02:23 23:34:30+01:00
GPS Coordinates (fra-FR)        : 53 deg 43' 1.92" N, 3 deg 4' 15.48" E, 27 m Above Sea Level
Software (fra-FR)               : 6.1.2
Model (fra-FR)                  : iPhone 4S
Avg Bitrate                     : 22.8 Mbps
Image Size                      : 1920x1080
Rotation                        : 90
[/color]




exiftool.exe File_Without_GPS.MOV
[color=green]
ExifTool Version Number         : 9.53
File Name                       : File_Without_GPS.MOV
Directory                       : .
File Size                       : 2.9 MB
File Modification Date/Time     : 2014:02:23 23:36:36+01:00
File Access Date/Time           : 2014:02:23 23:37:51+01:00
File Creation Date/Time         : 2014:02:23 23:37:51+01:00
File Permissions                : rw-rw-rw-
File Type                       : MOV
MIME Type                       : video/quicktime
Major Brand                     : Apple QuickTime (.MOV/QT)
Minor Version                   : 0.0.0
Compatible Brands               : qt
Movie Data Size                 : 3024327
Movie Data Offset               : 36
Movie Header Version            : 0
Create Date                     : 2014:02:23 22:36:34
Modify Date                     : 2014:02:23 22:36:36
Time Scale                      : 600
Duration                        : 1.03 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 2014:02:23 22:36:34
Track Modify Date               : 2014:02:23 22:36:36
Track ID                        : 1
Track Duration                  : 1.03 s
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 1920
Image Height                    : 1080
Clean Aperture Dimensions       : 1920x1080
Production Aperture Dimensions  : 1920x1080
Encoded Pixels Dimensions       : 1920x1080
Graphics Mode                   : ditherCopy
Op Color                        : 32768 32768 32768
Compressor ID                   : avc1
Source Image Width              : 1920
Source Image Height             : 1080
X Resolution                    : 72
Y Resolution                    : 72
Compressor Name                 : H.264
Bit Depth                       : 24
Video Frame Rate                : 24
Camera Identifier               : Back
Frame Readout Time              : 28512 microseconds
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2014:02:23 22:36:34
Media Modify Date               : 2014:02:23 22:36:36
Media Time Scale                : 44100
Media Duration                  : 1.07 s
Media Language Code             : und
Balance                         : 0
Handler Class                   : Data Handler
Handler Vendor ID               : Apple
Handler Description             : Core Media Data Handler
Audio Format                    : mp4a
Audio Channels                  : 1
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Purchase File Format            : mp4a
Model (fra)                     : iPhone 4S
Software Version (fra)          : 6.1.2
Create Date (fra)               : 2014:02:23 23:36:34+01:00
Make (fra)                      : Apple
Handler Type                    : Metadata Tags
Make (fra-FR)                   : Apple
Creation Date (fra-FR)          : 2014:02:23 23:36:34+01:00
Software (fra-FR)               : 6.1.2
Model (fra-FR)                  : iPhone 4S
Avg Bitrate                     : 23.4 Mbps
Image Size                      : 1920x1080
Rotation                        : 90
[/color]




OK, so the only different is the metatdata "GPS Coordinates (fra)" and "GPS Coordinates (fra-FR)" which are absent in the second file. So I try to copy these metatdata with this command :
exiftool -all= -tagsfromfile File_With_GPS.MOV -all:all File_Without_GPS.MOV

then I display metadatas on my file but the GPS location is not here

ExifTool Version Number         : 9.53
File Name                       : File_Without_GPS.MOV
Directory                       : .
File Size                       : 2.9 MB
File Modification Date/Time     : 2014:02:23 23:53:03+01:00
File Access Date/Time           : 2014:02:23 23:53:03+01:00
File Creation Date/Time         : 2014:02:23 23:53:03+01:00
File Permissions                : rw-rw-rw-
File Type                       : MOV
MIME Type                       : video/quicktime
Major Brand                     : Apple QuickTime (.MOV/QT)
Minor Version                   : 0.0.0
Compatible Brands               : qt
Movie Data Size                 : 3024327
Movie Data Offset               : 36
Movie Header Version            : 0
Create Date                     : 2014:02:23 22:34:30
Modify Date                     : 2014:02:23 22:34:31
Time Scale                      : 600
Duration                        : 1.03 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 2014:02:23 22:34:30
Track Modify Date               : 2014:02:23 22:34:31
Track ID                        : 1
Track Duration                  : 1.03 s
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 1920
Image Height                    : 1080
Clean Aperture Dimensions       : 1920x1080
Production Aperture Dimensions  : 1920x1080
Encoded Pixels Dimensions       : 1920x1080
Graphics Mode                   : ditherCopy
Op Color                        : 32768 32768 32768
Compressor ID                   : avc1
Source Image Width              : 1920
Source Image Height             : 1080
X Resolution                    : 72
Y Resolution                    : 72
Compressor Name                 : H.264
Bit Depth                       : 24
Video Frame Rate                : 24
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2014:02:23 22:34:30
Media Modify Date               : 2014:02:23 22:34:31
Media Time Scale                : 44100
Media Duration                  : 1.07 s
Media Language Code             : und
Balance                         : 0
Handler Class                   : Data Handler
Handler Type                    : Alias Data
Handler Vendor ID               : Apple
Handler Description             : Core Media Data Handler
Audio Format                    : mp4a
Audio Channels                  : 1
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Purchase File Format            : mp4a
Model (fra)                     : iPhone 4S
Software Version (fra)          : 6.1.2
Create Date (fra)               : 2014:02:23 23:36:34+01:00
Make (fra)                      : Apple
Avg Bitrate                     : 23.4 Mbps
Image Size                      : 1920x1080
Rotation                        : 90


So I tried with ffmpeg to get my GPS metadatas...
ffmpeg.exe -i File_With_GPS.MOV -i File_Without_GPS.MOV -map 1 -map_metadata 0 -c copy test.mov

But it dosen't works at all...

Does anyone have a solution to copy my GPS location from a video .MOV file to another one ?
I attach the 2 files (one with GPS location included and the other one without) to make tests, here.

Thank you.

Phil Harvey

ExifTool has the ability to write XMP to QuickTime MOV files, but it won't write the QuickTime GPSCoordinates.

Copying the QuickTime GPSCoordinates to XMP GPS tags would be simple using the pre-defined QuickTime Composite tags, but unfortunately these won't work with GPSCoordinates-fra or GPSCoordinates-fra-FR, so it will be more complicated, but still possible.

If writing these tags to XMP would be acceptable, then I can give you detailed instructions tomorrow after I am able to download your sample files.

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

schmurtz

Thanks a lot for your fast answer, you Will find my sample files here :
https://www.dropbox.com/sh/6xx94l3n0uwoypj/FpskQsVXyC
Regards.

Phil Harvey

OK, here is the command:

exiftool -tagsfromfile File_With_GPS.MOV -@ my.args File_Without_GPS.MOV

and here is the argument file (a.args):

-XMP:GPSLatitude<${GPSCoordinates-fra#;s/ .*//}
-XMP:GPSLongitude<${GPSCoordinates-fra#;s/\S+ (\S+).*/$1/}
-XMP:GPSAltitude<${GPSCoordinates-fra#;s/.* -?//}
-XMP:GPSAltitudeRef<${GPSCoordinates-fra#;s/.* //;$_=$_>=0?'Above':'Below'}


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

Phil Harvey

I have added an enhancement to ExifTool to generate default language tags, which will make this much simpler.  With ExifTool 9.54 (to be released on Saturday) you will be able to do this with the following command:

exiftool -tagsfromfile File_With_GPS.MOV "-gps*" File_Without_GPS.MOV

The complicated argument file will no longer be necessary.

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

schmurtz

Hi,

Thanks a lot for your help !
Your command line with the argument file works great but unfortunately this kind of metadatas are not read by the default "photos" application in the iphone. However your command line will be usefull to standardize metadata for the GPS location...

The functionality that I want to keep is showed in this video :
http://youtu.be/5mbf5r7hrsI?t=18s

Do you think that a solution exists to replicate the iphone's originals GPS metadatas ?

I tried with an hex editor but it is nor fast nor easy...

Phil Harvey

AtomicParsely is the application I recommend for writing MP4 atoms, but it would likely require some coding to do exactly what you want.

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

benmosher

Hi Phil,

Is there some major technical/spec limitation that prevents exiftool being enhanced to write QT atoms?

I'm very interested in solving this, but I am concerned there is some major blocker.

Phil Harvey

The problem is that video formats suck.  There is a complete lack of standardization in the way that metadata is written to QuickTime-format video files.  A number of different video formats use the QuickTime container, and the metadata is stored in different locations for most of them.

Also, the video standards documents are without exception poorly written and usually cost money to obtain, and the metadata is like an afterthought in this documentation, and is often incompletely defined.

And I lack a good library of video software to be able to test for compatibility if I do add the ability to write this information.

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