Use subtitle info to populate EXIF data

Started by mcq, May 24, 2024, 02:44:01 PM

Previous topic - Next topic

mcq

I fly drones and the video records subtitle data that has time, latitude, longitude, elevation, and camera parameters.  I have need to grab video frames and populate the grabbed frames with the time, latitude, longitude, elevation, and camera parameters from the subtitle for the grabbed frame.

Is there a way of doing this?

StarGeek

If I recall correctly, exiftool can read the subtitle stream for GPS data in certain files. Run exiftool on the file with the -ee (-extractEmbedded) option and see if GPS data shows up. If so, create a GPS track using the instructions under Inverse Geotagging.

At that point, your only problem is getting the correct timing information into the extracted frames.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

wywh

#2
Quote from: mcq on May 24, 2024, 02:44:01 PMvideo records subtitle data that has time, latitude, longitude, elevation, and camera parameters

By "subtitle data" do you mean a sidecar .srt text file? My DJI P3P records that in 1 second intervals and I occasionally manually copy GPS from it elsewhere (.srt has longitude,latitude so I must manually switch them when writing). The beginning of a .srt file looks like:

1
00:00:01,000 --> 00:00:02,000
HOME(29.9769,31.1351) 2023.09.09 18:15:51
GPS(29.9792,31.1342,20) BAROMETER:138.5
ISO:100 Shutter:30 EV: Fnum:F2.8

2
00:00:02,000 --> 00:00:03,000
HOME(29.9769,31.1351) 2023.09.09 18:15:52
GPS(29.9794,31.1344,20) BAROMETER:146.6
ISO:100 Shutter:30 EV: Fnum:F2.8

Apps like IINA by default read and superimpose .srt info to the .mp4 when playing the movie. I use that to check what the altitude has been at a certain point of the movie or use a text editor to check the lowest altitude, for example.

The DJI P3P .mp4 has a GPS as single UserData:GPSCoordinates from the beginning of the movie. Adding -ee does not reveal additional GPS.

- Matti

Phil Harvey

Would it be useful for ExifTool to be able to geotag images from the track in the .srt file?  Is this a format used by other models?  How consistent is the format (is the date/time always on a line that starts with "HOME"?).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: wywh on May 25, 2024, 05:00:13 AMBy "subtitle data" do you mean a sidecar .srt text file?

Some videos embed the GPS data as a subtitle stream. I had assumed it was srt, but actually checking the sample file I have (from a Thinkware Q800PRO), I'm not sure. The subtitle stream I had extracted from it was in srt, but I realize now that is only because I specified srt in the ffmpeg I used at the time. Checking now, I see it is saved as mov_text in the file and is formatted differently.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Just FYI: ExifTool does extract some formats of GPS from the subtitle track, but there are likely more out there that ExifTool doesn't yet recognize.  However, it doesn't yet recognize any .srt files.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).