Skip to content

Instantly share code, notes, and snippets.

@jareware
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jareware/787e0df8a19e735d9dbb to your computer and use it in GitHub Desktop.
Save jareware/787e0df8a19e735d9dbb to your computer and use it in GitHub Desktop.
A small bash-script for geotagging videos. Generates an SRT subtitle file with a running timestamp and GPS coordinates, indicating when and where the footage was shot. As the metadata's in a separate track (not burned onto the footage for example), you can hide it when it's not needed.

geodata-subtitle

A small bash-script for geotagging videos. Generates an SRT subtitle file with a running timestamp and GPS coordinates, indicating when and where the footage was shot. As the metadata's in a separate track (not burned onto the footage for example), you can hide it when it's not needed.

Dependencies

exiftool >= 9.52 is needed for reading video file metadata, and performing GPS interpolation.

To check that the tool works and your video file contains the necessary metadata, try:

$ exiftool -CreateDate -Duration GOPR1412.MP4
Create Date                     : 2014:05:27 08:47:48
Duration                        : 0:00:30

If the two fields aren't present with sensible values, geodata-subtitle may still able able to help you, but you'll likely need to hack around a bit. Reading the source might help.

Usage

$ geodata-subtitle GOPR1400.MP4 > GOPR1400.srt

The above example will only write the running timestamp to the SRT file. For a more comprehensive example:

$ geodata-subtitle GOPR1400.MP4 7:06:49 +9:00 path/to.gpx "GeoMaxExtSecs=86400 GeoMaxIntSecs=1800" > GOPR1400.srt

Starting from the right, all arguments can be omitted if the associated functionality isn't wanted. As to the arguments:

  1. GOPR1400.MP4: video file from which the metadata will be read. Won't be written to.
  2. 7:06:49: camera clock correction. The camera clock is assumed to run in local time where the material was shot, but it's never exactly right. This can be used to shift it in line with the time of the GPS instrument that was used, or just local time if no geotagging is needed. Pointing the camera to a clock once while shooting the video is generally really useful in validating this. Negative offsets are allowed.
  3. +9:00: the UTC offset of the location where the material was shot. This will affect geotagging: the camera is assumed to run local time (possibly corrected using the previous argument), and the GPS instrument is assumed to record times in UTC (they usually do), so the UTC offset compensates for this. Negative offsets are allowed.
  4. path/to.gpx: unsurprisingly, file to read GPS locations from. All formats supported by exiftool should work, not just GPX. Omitting this parameter will simply not attempt any geotagging, and just write out the timestamps.
  5. "GeoMaxExtSecs=86400 GeoMaxIntSecs=1800": Additional options for the geolocation interpolation. If you're getting Time is too far before track-warnings for example, consider setting GeoMaxExtSecs to a higher value (it'll make exiftool more tolerant of having to extrapolate missing positions; 86400 means one day). The options are documented here.

Author

Jarno Rantanen (@Jareware)

License: MIT

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment