Possible to extract GPS from Sony Video?

Started by dougransom, September 03, 2013, 01:52:16 PM

Previous topic - Next topic

dougransom

Hi,

I have a Sony HX-9V which I have recorded some geotagged video in mp4 format.  Is it possible to use ExifTool to find the GPS metadata?  Sony does something weird, since just running exiftool on the file doesn't load any gps metadata (though it works fine on stills from the same camera).  I suspect more than one GPS coordinate is stored the stream.

If exiftool can't do this out of the box, is it likely the API could be used to extract this information?  Is there a place where we can find documentation on how Sony stores the GPS info in video files?

Kudos to Sony for making a GPS enabled camera which records GPS metadata  in Videos nobody can seem access. 

Phil Harvey

ExifTool should extract the GPS from MTS files if you record in this format, but doesn't yet have the ability to extract GPS from MP4 files (although this is high on the to-do list).  If you have a small MP4 sample handy, it would be useful to add to my test files for when I get around to adding this feature.  If you could mail to philharvey66 at gmail.com That would be great.

Yes, it would have been nice if Sony wrote the GPS to the MP4 metadata like they should have done.

- 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 ($).

dougransom

I did send an email, if anyone else wants a sample geotagged MP4 from Sony HX-9V they can grab it (for now) at https://www.dropbox.com/s/z9zxgx3fb5eop5i/MAH01268.MP4


dougransom

Hi,  was any progress made on this?  I installed the latest exiftool, but I wouldn't know to set the command line to check.


Doug


Phil Harvey

...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 ($).

Phil Harvey

Update:

I couldn't get much done on this over the holidays because most of the work so far has been in searching for a format specification for the contents of the MOV mdat atom, which is hard to do from home over dialup.  But I have worked on this over the last two days from my office.  The QuickTime file format specification is good for most metadata, but I can't find where it describes the structure of the mdat atom contents, which is where the streamed GPS will be found.  For lack of appropriate documentation, I have also tried to reverse engineer the ffmpeg code, but haven't had much success with this either.  This is frustrating because I can decode both ends (the high-level QuickTime container, and the low-level H264 compressed video stream which should contain the GPS), but I haven't yet managed to figure out how this is packed (along with the other streams) in the MOV mdat atom.

I haven't given up, but right now it isn't looking good for having this feature in the next release.

I should point out that this is a systemic problem with video formats.  Many of the video format specifications are imprisoned by the ISO, and far too expensive for small, independent software developers like me.  I fear that the mdat video data may fall into this category.

- 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 ($).

Phil Harvey

#6
Bad news.  I haven't been able to make any progress on this feature, so it won't be appearing in the next release.

- Phil

Edit: If there is anyone out there who knows where to find the documentation on the video stream data format in MOV and/or MP4 files and how the GPS is stored, please let me know.
...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 ($).

dvazquez

Hi Phil,

I think that this link could be hepfull for you:
http://www.registratorviewer.com/index_en.html

They have a program that can extract the GPS information from .mov videos and save it in a text file. I have send him a mail asking something and he replyed me fast. Maybe he could give you some tips about how to do it.

Good luck!!

Phil Harvey

Quote from: dvazquez on January 15, 2014, 09:20:52 AM
They have a program that can extract the GPS information from .mov videos and save it in a text file. I have send him a mail asking something and he replyed me fast. Maybe he could give you some tips about how to do it.

You're right, Vadim is fast at responding, but it doesn't seem as if he can help.  This was his response:

       "There are several tens of GSP format inside MOV,
        I have supported. Every China developer trying
        to invent its own way how to pack GPS with video.
        And yes - no any documentation exists...

        My project is not opensource, so I cannot get you
        any sources, sorry. I have no format docs too."


(When he says "China developer", I think he is talking about the makes of popular dashcams in Russia.)

- 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 ($).

postsoup

Quote from: Phil Harvey on January 10, 2014, 11:21:00 AM
Bad news.  I haven't been able to make any progress on this feature, so it won't be appearing in the next release.

- Phil

Edit: If there is anyone out there who knows where to find the documentation on the video stream data format in MOV and/or MP4 files and how the GPS is stored, please let me know.

The mdat atom is used to store RAW essence. This can be almost *anything* and is defined by the sample descriptions in the track.  The Sample Descriptions will say what the media is (for example raw DV essence).   The track also lists all the samples, which are generally offsets into the essence stored in the mdat.   So the mdat has no defined structure, although you will quite often find a series of video frames one after the other - but the boundaries of these are defined in the sample table, which is sort of your table of contents for the mdat

So, its not expected to read the mdat directly as such, but to read the sample descriptions and the sample table, then read the raw data out of the mdat according to the sample table offset, and interpret that data according to the sample description.

So, you would need the raw media essence specification for any types you are interested in.  Some of these things are ISO specifications (like DV100 format), but others are probably more freely available.

its probably the same for mp4 - the above information is drawn from experience with quicktime .mov files.

Hope this helps.

Phil Harvey

...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 ($).

gfields

Hi

I was following this thread for a while as I have 2 cameras from which I have been attempting to retrieve GPS data. Interestingly, I came here for information about how to deal with the exif data from the still images.

In case you are still interested in this, from my experience the GPS data stored with video files is not related to exif metadata, as of course the data applies to the whole file. GPS data must apply to the moment, so is stored as timed text.

Our first camera was a Contour+. The GPS data is embedded in a timed text subtiltle stream in the .mov file which can be seen if subtitles are turned on in the video display. This is not supported by Windows Media Player, but can be seen in VLC or the like. I use a program by the name of CGPS TrackXtracT to extract the stream. It was developed by a Contour user and is free to use, but I don't think this is supported any more since the Contour forum no longer exists.
http://kjh.ca/contour_mods/doku.php?id=gps_extract:start
Other programs can do it, but many (including MP4Box) do not read apple text well.

XMediaRecode is also good but does not specifically support GPS data. http://www.xmedia-recode.de/en/index.html

The other camera is a Sony HDR-AS30V which we bought because of the unreliablity of the Contours. The GPS data is not embedded in the .mp4 video stream, but stored as a timed text log file which is buried in the file structure on the SD card. Of course the video file must be matched to the log file by date/time as the names are not the same.
I have had some success at formatting the raw GPS data and embedding the text stream back to the mp4 file, but as WMP does not support subtitles in mp4 or mov files it is not much help in our corporate environment, so a new interface was required to display our proprietory location data.

No doubt there are as many other ways to store GPS data as there are devices to record it, but I hope this helps somebody.

Phil Harvey

Thanks, this is useful information.

- 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 ($).

tadej

Quote from: Phil Harvey on September 03, 2013, 01:56:06 PM
ExifTool should extract the GPS from MTS files if you record in this format,
- Phil
Hi Phil,
I did some test with MTS format and EXIF shows gps position for a file.
I suppose this a position of the first frame.
Is there a way to get gps positions for each frame for example.
regards
Dusan

Phil Harvey

...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 ($).