ExifTool Forum

ExifTool => Newbies => Topic started by: haimat on June 03, 2021, 09:44:46 AM

Title: Generating/writing GPS data from MP4 file into video frames
Post by: haimat on June 03, 2021, 09:44:46 AM
Hello all,

I have never worked with ExifTool, but it seems this tool might help in my situation, so I would like to ask for your help. I have an MP4 video file from a GoPro camera. That video file contains a GPS data stream. What I want is to a) extract each frame from that video and save them as JPG images, and b) write the correct GPS/geolocation tags into each of these images. So far I was able to extract all GPS data from the video file into a GPX (XML) file.

There seems to be catch though: When I look into that GPX file I can see the time string under "metadata" in the header of the file = 2021-05-28T08:54:24Z. However, when I look at the MP4 file itself via ffprobe the creation_time = 2021-05-28T10:22:18.000000Z. Thus apparently the GPS time stamps and the video file time stamp are not in sync.

Now is there a way with ExifTool to achieve what I want? Can I extract the video frames as image files AND write the GPS/geodata information into each image AND take care of the time difference? It would be fine for me to use another tool like ffmpeg in order to extract all video frames into images as a first step, as long as my overall goal can be achieved. Is ExifTool the right tool for this job?

Thanks in advance for your help!
Title: Re: Generating/writing GPS data from MP4 file into video frames
Post by: Phil Harvey on June 03, 2021, 09:52:08 AM
Synchronization between the video and gps is difficult.  If you can determine the exact time of each video frame, you can use the exiftool -geotag and -geosync options to read the GPX file and geotag the extracted frames.  The problem is determining the proper -geosync time.  If you just need to be within a second, this should be easy.  But if you need sub-second accuracy, you'll need to devise some sort of calibration scheme.  All you need is one frame that was taken at a unique, known location to calibrate the entire video (assuming clock drift is small).  I did this for one of my videos by finding a picture when we passed a known landmark at high speed.

- Phil
Title: Re: Generating/writing GPS data from MP4 file into video frames
Post by: haimat on June 03, 2021, 10:17:15 AM
Hey Phil,

thank you very much for your quick reply. I could extract all frames from the video into a folder via ffmpeg. But I guess then each of these images would need the correct exif information within them in order for ExifTool to work correctly. What are the requirements here so that the -geotag and -geosync options work correctly - I guess each image needs the DateTimeOriginal exif flag, right? Is there anything else I need to take care of when extracting the video frames into images?
Title: Re: Generating/writing GPS data from MP4 file into video frames
Post by: StarGeek on June 03, 2021, 12:31:27 PM
The DateTimeOriginal tag would work by default but any time tag would work by explicitly setting the Geotime tag (see Geotime (https://exiftool.org/geotag.html#geotime) on the Geotagging with ExifTool page (https://exiftool.org/geotag.html)).