Closed mindeng closed 1 month ago
Hi @xandkar
Version 2.0 will be released soon. Here's what the new API looks like:
use nom_exif::*;
fn main() -> Result<()> {
let mut parser = MediaParser::new();
// The file can be an image, a video, or an audio.
let ms = MediaSource::file_path("./testdata/exif.heic")?;
if ms.has_exif() {
// Parse the file as an Exif-compatible file
let mut iter: ExifIter = parser.parse(ms)?;
let exif: Exif = iter.into();
assert_eq!(exif.get(ExifTag::Make).unwrap().as_str().unwrap(), "Apple");
} else if ms.has_track() {
// Parse the file as a track
}
let ms = MediaSource::file_path("./testdata/meta.mov")?;
if ms.has_track() {
// Parse the file as a track
let info: TrackInfo = parser.parse(ms)?;
assert_eq!(info.get(TrackInfoTag::Make), Some(&"Apple".into()));
assert_eq!(info.get(TrackInfoTag::Model), Some(&"iPhone X".into()));
assert_eq!(info.get(TrackInfoTag::GpsIso6709), Some(&"+27.1281+100.2508+000.000/".into()));
assert_eq!(info.get_gps_info().unwrap().latitude_ref, 'N');
assert_eq!(
info.get_gps_info().unwrap().latitude,
[(27, 1), (7, 1), (68, 100)].into(),
);
}
// `MediaSource` can also be created from any `Read`, such as a `TcpStream`:
// let ms = MediaSource::tcp_stream(stream)?;
Ok(())
}
If you are interested, you can check out the v2 branch.
What do you think? I'd like to hear your opinion, thank you!
*.webm
, request from @xandkar