Sightseer
Posts: 9
Exporting still image with GPS coordinates in EXIF

Hi,

 

I'm about to buy a Hero 7 Black and the only thing that is stopping me is that I spent a whole trying to extract a still image from an MP4 generated by GoPro that contains telemetry data. My discoveries so far:

 

  1. Dashware can get the GPS track but can't export still images (or at least I'm dumb and I can't see how).
  2. Quik exports images but does not write the GPS tags in the EXIF. From what I read Quik still does not support reading telemetry data.
  3. Premiere - same story.
  4. Tried some other Linux software: avidemux, openshot, blender - no success.

I was wondering - maybe FFMpeg? Cause it certainly sees the metadata track and has the capability to export subsets of tracks (but I'm not sure it can translate this track to EXIF fields):

 

Stream #0:3(eng): Data: none (gpmd / 0x646D7067), 45 kb/s (default)
Metadata:
creation_time : 2018-08-27T01:28:44.000000Z
handler_name : GoPro MET

Nomad
Posts: 107
Re: Exporting still image with GPS coordinates in EXIF

@thegrave 

ffmpeg can extract individual frames (photos) from the video and exiftool can be used to add the gps data to the photos.

Sightseer
Posts: 9
Re: Exporting still image with GPS coordinates in EXIF
Care to show an example? Can't imagine how I can view or pass GPS coordinates of a frame with ffmpeg, let alone pass them over to exiftool.
Hiker
Posts: 27
Re: Exporting still image with GPS coordinates in EXIF

My guess is by "add" they mean add them back manually, interpolated either visually or by time, manually. Or... if ffmpeg throws a timestamp on the still (I've never used it...) Exiftool can easily interpolate the GPS coordinates for individual image files from a GPX track using the -geotag function.

 

http://owl.phy.queensu.ca/~phil/exiftool/geotag.html

Nomad
Posts: 107
Re: Exporting still image with GPS coordinates in EXIF
[ Edited ]

@thegrave You wouldn't view or pass GPS coordinates of a frame with ffmpeg. You would use ffmpeg to extract frames from the video to jpg files. Then you would use exiftool to add the GPS coordinates to the jpg files. I'll post an example

Nomad
Posts: 107
Re: Exporting still image with GPS coordinates in EXIF

@gravyhole Sort of. ffmpeg doesn't add a timestamp to the extracted frames so you would need to have a script that calculates the time of the frame then use that time to interpolate the GPS coordinates using the exiftool function you posted.

Nomad
Posts: 107
Re: Exporting still image with GPS coordinates in EXIF
[ Edited ]

If it's just one frame then the calculation of the timestamp and the lookup of the GPS coordinates could be done manually. Then the GPS coordinates could be added to the frame/jpg using exiftool.

 

@thegrave is the intent to do this for just one frame from the video or for multiple frames? If multiple, how many?

Sightseer
Posts: 9
Re: Exporting still image with GPS coordinates in EXIF
Let's say there are 5-10 pics per video worth extracting but still this method would be a real pain in the ass from what you mention. I don't find a reliable way to get the current frame number from any video player so this means I either need to re-encode the whole video file with ffmpeg so that frame numbers are overlaid:

https://stackoverflow.com/questions/15364861/frame-number-overlay-with-ffmpeg

Or pause the player and extract one second which will be 60 images if it's a 4k60p video for example.

Another option would be to play the video file in a VM running something like Premiere where you can do frame-by-frame navigation and display current frame count but I'm starting to wonder whether 16GB of RAM will be enough for bigger files...

For the sake of the conversation - how do you extract with ffmpeg the GPS metadata associated with a frame?
Hiker
Posts: 27
Re: Exporting still image with GPS coordinates in EXIF

I'm interested in this  (but no experience using ffmpeg) but it doesn't look like this is possible. Someone can correct me if  I'm wrong, but given that threads on extracting an exact frame number (let alone timestamp) for an original frame show that this isn't simple, finding GPS coordinates based on the individual frame isn't possible directly.

 

As I understand it, there are no GPS coordinates mapped to individual frames as there would be with a single camera image from a still camera with a gps chip embedding coordinates into the metadata. Instead, GPS tracklogs alongside video (GoPro included) are separate streams (stored in various places and in various ways, making it interesting for developers to try and pull them out and make them comprehensible).

 

You can see some of the ramifications of this by looking at a GPX (or csv) of GoPro gps data extracted by dashware or GPMD2CSV: A hyperlapse I shot has 3 GPS stamps per second but 30 video frames per second. A 60fps video I shot has GPS coordinate data at 20x per second.

 

The best you'd be able to do -- if you could get a perfect timestamp for a frame off the video -- would be interpolating between the known GPS coordinates. Exiftool can do that for you via -geotag, or you can do it yourself using something like lightroom. Since any timestamp you got on a frame would be an interpolation, you'd be locating the frame by matching one interpolation to another. Probably more than adequate, but not simple.

 

If I were pulling frames, I'd just snapshot them in VLC player, fix the individual frame datetimeoriginal field to the video's shot datetime + elapsed time to the frame, and either let exiftool -geotag it (or them) from the exported gpx file, or drop them on a map in lightroom or similar in the next window. This would obviously only be tolerable for a handful of frames at a time.

 

Maybe there's a better way.

Nomad
Posts: 107
Re: Exporting still image with GPS coordinates in EXIF

@thegrave 

I'm not suggesting that you extract GPS metadata using ffmpeg.

It might be easier to suggest possible solutions if you could explain at a high level what you are ultimately trying to do with the MP4 and the images you export and GPS tag from the MP4.

Sightseer
Posts: 9
Re: Exporting still image with GPS coordinates in EXIF
Hm, my understanding was that telemetry data is embedded in the MP4 file as a separate stream. Hence only handful of software was able to read it. At least Dashware is generating some sort of a track (I can't find a way to export) purely based on an MP4 file, I'm not feeding it anything else.
Hiker
Posts: 27
Re: Exporting still image with GPS coordinates in EXIF

Dashware already exports the data to a CSV, which is found in the project save folder alongside the other saved project files. If and when you grab the correct data profile, and the sync is OK, it then does the overlays and gauges correctly (though not always, in my experience. Hyperlapses seem to vex it, as they vex Quik).

 

A GPX  (as well as few different CSV) exports of the telemetry can be obtained via GPMD2CSV's batch process. These can also easily be used in dashware with the correct data profile. However,  (again, as I understand it) there's no per-frame GPS data to be obtained by any extraction method, because  (as outlined above) this does not exist. There's video stream. There's telemetry and  GPS data in a separate stream, and these are not mapped to each other frame by frame. Any software mapping overlay is interpolating map position and frame display based on a synchronization routine from a more-or-less known position at a more-or-less known time (either automatic or manual).

Nomad
Posts: 107
Re: Exporting still image with GPS coordinates in EXIF
[ Edited ]

@thegrave 

Let me clarify. Yes, you could use ffmpeg to extract the metadata from the MP4. But, it would be at the track (aka stream) level. The GPS data associated with a specific frame would need to be done using another method from the extracted track data.

Again, could you please explain at a high level what you are trying to achieve?

Sightseer
Posts: 9
Re: Exporting still image with GPS coordinates in EXIF
1 second precision is good enough, as long as you can match the GPX track to the video track. Something along these lines can be done I think:

1) Extract a GPX (either from MP4 or misc telemetry files on the GoPro)
2) Check the file creation timestamp in the EXIF of the MP4
3) Mark down the time of extracting the JPGs with 1s precision and hand them over to ffmpeg
4) Check the duration from the start frame to the target frame and add this time difference to the original file creation time from EXIF
5) Grab coordinates from GPX
6) Apply geotag with exiftool.

(Even semi-)Automating this will be a real pain in the ass IMHO. I started by simply comparing a movie EXIF file creation timestamp and GPX exported from here:

https://tailorandwayne.com/gopro-telemetry-extractor/

There is a big discrepancy in timing, about 10 minutes (and couple of hours but let's say this is due to the timezone). I guess this telemetry extractor is buggy.

Btw snapshotting from VLC player will give you at max your monitor resolution and video stream will be almost always certainly higher so not sure it's a good idea.

Just saw this other topic:

https://community.gopro.com/t5/GoPro-Metadata-Visualization/DroneViewer-video-and-data-visualizer-no...

Advertisement video claims to be able to do what I need but on MacOS only:

https://youtu.be/Rw1PsbiB8q0?t=193

I got Windows 7 and 10 but software is buggy as hell and can't load a single video with it, let alone export a JPG. Anyone caring to try?
Tourist
Posts: 10
Re: Exporting still image with GPS coordinates in EXIF

This may help: The Mac version of DroneViewer embeds GoPRO GPS coordinates in the EXIF section of the JPG and also in the title of the image:

 

Sightseer
Posts: 9
Re: Exporting still image with GPS coordinates in EXIF
Mucho nice!

I can only hope this is valid for the Windows version nowadays as well. Running another VM with MacOS just because of this software makes me wanna shoot myself in the foot :)