If you own a DJI drone and have imported videos from it to your Apple Photos library, you may have noticed that the GPS coordinates are not recognised in Apple’s software.

This is because DJI writes the GPS data to a different metadata field than what Photos.app expects. I don’t know if this is a bug on DJI’s or Apple’s side, but it’s annoying nonetheless.

Luckily, we can use exiftool to extract the GPS coordinates and the macOS avmetareadwrite CLI tool to fix the issue.

First, we’ll need to extract the coordinates and video creation date from the video file. Notice that the GPS coordinates have specific formatting.

exiftool -ignoreMinorErrors \
  -c %+.10f \
  -p '${gpslatitude;s/([-+])/$1.("0"x(14-length $_))/e}${gpslongitude;s/([-+])/$1.("0"x(15-length $_))/e}' \
  DJI_0001.MP4

exiftool -CreateDate -d '%Y-%m-%dT%H:%M:%SZ' DJI_0001.MP4

Next, create a metadata plist file, DJI_0001.plist. avmetareadwrite is picky about the coordinate format and will silently fail if the coordinates are not formatted correctly.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>mdta/com.apple.quicktime.location.ISO6709</key>
  <string>+60.1813000000+025.0086000000</string>
  <key>common/location</key>
  <string>+60.1813000000+025.0086000000</string>
  <key>common/creationDate</key>
  <string>2024-05-31T11:42:00Z</string>
  <key>common/make</key>
  <string>DJI</string>
  <key>common/model</key>
  <string>Mini 2</string>
</dict>
</plist>

We also need to convert the MP4 file to MOV using ffmpeg. This is a lossless conversion and should complete in seconds.

ffmpeg -i DJI_0001.MP4 \
  -ignore_unknown \
  -acodec copy \
  -vcodec copy \
  -scodec mov_text \
  -dcodec copy \
  -movflags use_metadata_tags \
  -f mov DJI_0001_TMP.MOV

And finally, append the metadata to the MOV file:

avmetareadwrite --append-metadata=DJI_0001.plist DJI_0001_TMP.MOV DJI_0001.MOV

The DJI_0001.MOV file can now be imported into Photos.app, and it should recognise the location, creation date, and camera metadata as expected.

I’ve created a slightly wonky script to automate this process. It’s overly picky about the working directory and should be run from the folder that contains the source video files and I’m sure there might be other bugs lurking in there as well.