GabrielZ

Q: How to transfer GPS coordinates from one movie to another using Applescript?

When I export a movie from the Photos app and play it in Quicktime Player,

then QTP gives me the location where the movie was recorded:

geo.png

Now, I would like to set the location of another movie to exactly the same location, using Automator or Applescript.

 

Could anyone please give me a hint how to do that? Is it possible?

 

The reason why I want to do this is that I would like to improve an Automator workflow I wrote that helps with compressing movies that I keep in my Photos library (i.e., reduce the file size).

You can find the workflow here (http://www.informatik.uni-bremen.de/~zach/software/index.html#compress_movies_in _photos), if you are interested.

 

Any hints, pointers, and suggestions will be highly appreciated.

 

Best regards,

Gabriel.

MacBook Pro with Retina display, OS X El Capitan (10.11.2), iPhone 6S, always latest iOS

Posted on Aug 10, 2016 5:34 PM

Close

Q: How to transfer GPS coordinates from one movie to another using Applescript?

  • All replies
  • Helpful answers

  • by Camelot,Helpful

    Camelot Camelot Aug 11, 2016 6:04 PM in response to GabrielZ
    Level 8 (47,243 points)
    Mac OS X
    Aug 11, 2016 6:04 PM in response to GabrielZ

    Tricky to do in standalone AppleScript, but easy if you install a copy of exiftool

     

    Then you can extract the GPS coordinates via something like:

     

    do shell script "/usr/local/bin/exiftool -GPSPosition some.JPG"

     

    You can also use exiftool to copy the tags from one file to another:

     

    do shell script "/usr/local/bin/exiftool -tagsFromFile source.jpg -GPSLongitude -GPSLatitude dest.jpg"

     

    This will copy the GPS Longitude and Latitude tags from source.jpg to dest.jpg

  • by GabrielZ,

    GabrielZ GabrielZ Aug 11, 2016 6:11 PM in response to Camelot
    Level 1 (37 points)
    Desktops
    Aug 11, 2016 6:11 PM in response to Camelot

    Thanks a million. This sounds like the perfect solution - alas, it does not seem to work on my side.

    exifTool seems to transfer a number of tags, including several GPS related tags.

    Still, neither Quicktime Player nor Photos app show the location.

    Maybe it is because exifTool does not transfer "GPS Coordinates", maybe it is because it changes the order of the tags.

     

    Here are the tags in the original:

    % exiftool-5.24 IMG_7441.MOV
    ExifTool Version Number         : 10.25
    File Name                       : IMG_7441.MOV
    Directory                       : .
    File Size                       : 56 MB
    File Modification Date/Time     : 2016:05:12 19:29:06+02:00
    File Access Date/Time           : 2016:08:12 02:33:41+02:00
    File Inode Change Date/Time     : 2016:08:12 02:06:52+02:00
    File Permissions                : rwxr-xr-x
    File Type                       : MOV
    File Type Extension             : mov
    MIME Type                       : video/quicktime
    Major Brand                     : Apple QuickTime (.MOV/QT)
    Minor Version                   : 0.0.0
    Compatible Brands               : qt
    Movie Data Size                 : 58888277
    Movie Data Offset               : 36
    Movie Header Version            : 0
    Create Date                     : 2016:05:12 18:29:06
    Modify Date                     : 2016:05:12 18:29:34
    Time Scale                      : 600
    Duration                        : 27.52 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                   : 5
    Track Header Version            : 0
    Track Create Date               : 2016:05:12 18:29:06
    Track Modify Date               : 2016:05:12 18:29:34
    Track ID                        : 1
    Track Duration                  : 27.52 s
    Track Layer                     : 0
    Track Volume                    : 100.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                : 29.978
    Balance                         : 0
    Audio Format                    : mp4a
    Audio Channels                  : 1
    Audio Bits Per Sample           : 16
    Audio Sample Rate               : 44100
    Purchase File Format            : mp4a
    Matrix Structure                : 1 0 0 0 1 0 0 0 1
    Media Header Version            : 0
    Media Create Date               : 2016:05:12 18:29:06
    Media Modify Date               : 2016:05:12 18:29:34
    Media Time Scale                : 600
    Media Duration                  : 27.52 s
    Media Language Code             : und
    Gen Media Version               : 0
    Gen Flags                       : 0 0 0
    Gen Graphics Mode               : ditherCopy
    Gen Op Color                    : 32768 32768 32768
    Gen Balance                     : 0
    Handler Class                   : Data Handler
    Handler Vendor ID               : Apple
    Handler Description             : Core Media Data Handler
    Other Format                    : mebx
    Handler Type                    : Metadata Tags
    GPS Coordinates                 : 38 deg 42' 57.24" N, 9 deg 8' 24.36" W, 41.245 m Above Sea Level
    Make                            : Apple
    Model                           : iPhone 6s
    Software                        : 9.3.1
    Creation Date                   : 2016:05:12 19:29:06+01:00
    Avg Bitrate                     : 17.1 Mbps
    GPS Altitude                    : 41.245 m
    GPS Altitude Ref                : Above Sea Level
    GPS Latitude                    : 38 deg 42' 57.24" N
    GPS Longitude                   : 9 deg 8' 24.36" W
    Image Size                      : 1920x1080
    Megapixels                      : 2.1
    Rotation                        : 0
    GPS Position                    : 38 deg 42' 57.24" N, 9 deg 8' 24.36" W
    

    Then I call /opt/local/bin/exiftool-5.24 -tagsFromFile /private/tmp/IMG_7441.MOV /private/tmp/IMG_7441.m4v 

    And here are the tags of IMG_7441.m4v afterwards:

    ExifTool Version Number         : 10.25
    File Name                       : IMG_7441.m4v
    Directory                       : .
    File Size                       : 24 MB
    File Modification Date/Time     : 2016:08:12 03:06:12+02:00
    File Access Date/Time           : 2016:08:12 03:06:12+02:00
    File Inode Change Date/Time     : 2016:08:12 03:06:12+02:00
    File Permissions                : rw-r--r--
    File Type                       : M4V
    File Type Extension             : m4v
    MIME Type                       : video/x-m4v
    Major Brand                     : Apple TV (.M4V)
    Minor Version                   : 0.0.1
    Compatible Brands               : M4VH, M4V , M4A , mp42, isom
    Movie Header Version            : 0
    Time Scale                      : 600
    Duration                        : 27.52 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               : 2016:05:12 18:29:06
    Track Modify Date               : 2016:05:12 18:29:34
    Track ID                        : 1
    Track Duration                  : 27.52 s
    Track Layer                     : 0
    Track Volume                    : 100.00%
    Balance                         : 0
    Audio Format                    : mp4a
    Audio Channels                  : 2
    Audio Bits Per Sample           : 16
    Matrix Structure                : 1 0 0 0 1 0 0 0 1
    Media Header Version            : 0
    Media Create Date               : 2016:05:12 18:29:06
    Media Modify Date               : 2016:05:12 18:29:34
    Media Time Scale                : 600
    Media Duration                  : 27.52 s
    Media Language Code             : und
    Handler Description             : Core Media Video
    Graphics Mode                   : srcCopy
    Op Color                        : 0 0 0
    Compressor ID                   : avc1
    Source Image Width              : 1280
    Source Image Height             : 720
    Bit Depth                       : 24
    Color Representation            : nclx 1 1 1
    Video Field Order               : Progressive; 0
    Pixel Aspect Ratio              : 1:1
    Handler Type                    : Metadata
    Encoded By                      : Mac OS X v10.11.6 (CMA 953, CM 1731.15.206, x86_64)
    Movie Data Size                 : 25456310
    Movie Data Offset               : 17936
    XMP Toolkit                     : Image::ExifTool 10.25
    GPS Altitude Ref                : Above Sea Level
    GPS Latitude                    : 38 deg 42' 57.24" N
    GPS Longitude                   : 9 deg 8' 24.36" W
    Creation Date                   : 2016:05:12 19:29:06+01:00
    Image Height                    : 1080
    Image Width                     : 1920
    Make                            : Apple
    Camera Model Name               : iPhone 6s
    Software                        : 9.3.1
    X Resolution                    : 72
    Y Resolution                    : 72
    Create Date                     : 2016:05:12 18:29:06
    Modify Date                     : 2016:05:12 18:29:34
    Audio Sample Rate               : 44100
    Video Frame Rate                : 29.978
    Avg Bitrate                     : 7.4 Mbps
    GPS Altitude                    : 41.2 m Above Sea Level
    GPS Latitude Ref                : North
    GPS Longitude Ref               : West
    Image Size                      : 1920x1080
    Megapixels                      : 2.1
    Rotation                        : 0
    GPS Position                    : 38 deg 42' 57.24" N, 9 deg 8' 24.36" W
    
  • by Camelot,

    Camelot Camelot Aug 11, 2016 7:27 PM in response to GabrielZ
    Level 8 (47,243 points)
    Mac OS X
    Aug 11, 2016 7:27 PM in response to GabrielZ

    I'm confused...

     

    Still, neither Quicktime Player nor Photos app show the location.

     

    Are you saying that these are not the co-ordinates:

     

    GPS Altitude Ref                : Above Sea Level

    GPS Latitude                    : 38 deg 42' 57.24" N

    GPS Longitude                   : 9 deg 8' 24.36" W

     

    My code, as written above, should work. You might be getting caught out with the difference between EXIF tag names and descriptions - the default output of exiftool is description, which is something like 'GPS Latitude', whereas the actual tag name is 'GPSLatitute' (no spaces). You need to specify the tag names to copy, not the description (which is what my example does above). You can use exiftool -s to see the data with EXIF names rather than descriptions.

  • by GabrielZ,

    GabrielZ GabrielZ Aug 12, 2016 3:48 AM in response to Camelot
    Level 1 (37 points)
    Desktops
    Aug 12, 2016 3:48 AM in response to Camelot

    Sorry for not being clear.

     

    Yes, the coordinates are correct. But Quicktime Player does not show them when I open the video in QTP and do "Show Movie Inspector".

     

    I executed:

      exiftool-5.24 -tagsFromFile IMG_7441.MOV IMG_7441.m4v

    which should copy all tags, shouldn't it?



  • by GabrielZ,

    GabrielZ GabrielZ Aug 12, 2016 3:56 AM in response to Camelot
    Level 1 (37 points)
    Desktops
    Aug 12, 2016 3:56 AM in response to Camelot

    Thanks a lot for the tip with the -s option. So, I also tried this:

    % /opt/local/bin/exiftool-5.24 -tagsFromFile IMG_7441.MOV -GPSCoordinates IMG_7441.m4v
    Warning: Sorry, gpscoordinates is not writable - IMG_7441.MOV
    Warning: No writable tags set from IMG_7441.MOV
        0 image files updated
        1 image files unchanged
    % /opt/local/bin/exiftool-5.24 -tagsFromFile IMG_7441.MOV -GPSPosition IMG_7441.m4v
    Warning: Sorry, gpsposition is not writable - IMG_7441.MOV
    Warning: No writable tags set from IMG_7441.MOV
        0 image files updated
        1 image files unchanged
    
  • by Camelot,

    Camelot Camelot Aug 12, 2016 5:15 PM in response to GabrielZ
    Level 8 (47,243 points)
    Mac OS X
    Aug 12, 2016 5:15 PM in response to GabrielZ
    Warning: Sorry, gpscoordinates is not writable - IMG_7441.MOV 

     

    Ahh, this is an oddity that isn't apparent from the command line tool.

     

    The GPS Coordinates/Position tag is, essentially, a virtual tag that is generated from the two GPS Longitude and GPS Latitude tags. If you copy those two tags (as I did in my earlier example), the GPS Position tag will (automagically) update to reflect the new values.

     

    That said, it isn't clear to me why your example to copy all the tags didn't work - although I would argue against that approach unless you're confident that the values such as resolution, encoding settings, duration, etc. are all consistent.

  • by GabrielZ,

    GabrielZ GabrielZ Aug 13, 2016 1:21 PM in response to Camelot
    Level 1 (37 points)
    Desktops
    Aug 13, 2016 1:21 PM in response to Camelot

    I did this:

    % exiftool-5.24 -tagsFromFile IMG_7441.MOV -GPSLatitude IMG_7441.m4v
    % exiftool-5.24 -tagsFromFile IMG_7441.MOV -GPSLongitude IMG_7441.m4v
    % exiftool-5.24 -tagsFromFile IMG_7441.MOV -GPSAltitude IMG_7441.m4v
    % exiftool-5.24 -tagsFromFile IMG_7441.MOV -GPSAltitudeRef IMG_7441.m4v
    

    And, viola, IMG_7441.m4v does have the same values for the tags GPSLatitude etc., like IMG_7441.MOV, but when I import the file in Photos or open it with Quicktime Player, no location is shown. So, I conjecture that these tags are not evaluated by Photos nor Quicktime Player.

  • by Camelot,

    Camelot Camelot Aug 13, 2016 8:45 PM in response to GabrielZ
    Level 8 (47,243 points)
    Mac OS X
    Aug 13, 2016 8:45 PM in response to GabrielZ

    when I import the file in Photos or open it with Quicktime Player, no location is shown

    Oh wow. That's not what I expected, either.

     

    The only other oddity is the 'GPS Coordinates' entity in the source file. I wonder if that's what it's feeding off instead of discreet Long/Lat tags. Try copying that tag over and see if it helps, otherwise I'm at a loss...