mozilla / mp4parse-rust

Parser for ISO Base Media Format aka video/mp4 written in Rust.
Mozilla Public License 2.0
405 stars 62 forks source link

question: extracting GPS metadata ? #365

Closed yuribudilov closed 2 years ago

yuribudilov commented 2 years ago

hello everyone, happy 2022.

I have a question: I have a lot of MP4 and MOV video files (sources: Android phones and Apple iPhones).

I want to extract the GPS latitude/longitude coordinates and date/time when the video was taken from them, using Rust.

Can I do this using this crate?

Currently I use exiftool command line utility to do this but I want to be able to do it directly from a Rust program (or worst case, from C API).

baumanj commented 2 years ago

No, that's not something that's currently supported. We may accept a patch, though. Are you interested in implementing it?

baumanj commented 2 years ago

From a quick search of crates.io, https://crates.io/crates/kamadak-exif may provide what you want. I don't have any experience with it, so I can't provide a recommendation either way.

yuribudilov commented 2 years ago

I thank you very much!! I will take anything that works directly from Rust. If it is a easy-to-use Rust FFI wrapper, it will do also.

So far, embarrassingly enough for Rust, LOL, I had to use Perl utility exiftool.exe to extract GPS and other video metadata and save the CLI utility output on text file. Then I use Rust to parse that output file. It works, but it is slow and a totally unsatisfying solution, I am quite ashamed of having done this. So if there is a pure Rust solution to handle reading MP4 and MOV to extra all metadata then I am 1000% for it. There is Rust MP4 crate but it also does not support extracting GPS metadata, they may put it on their TODO list.

The kamadak-exif documentation states is only supports JPEG, photos. There is no mention on any video support for MP4/MOV. I have successfully used another Rust library to obtain EXIF metadata for JPG files already, https://github.com/kornelski/rexif. Sadly, it also does not support video MP4/MOV formats.