-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cd50b06
Showing
31 changed files
with
4,072 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "gpmf-rs" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
binread = "2.2" | ||
rayon = "1.5.3" | ||
time = {version = "0.3", features = ["formatting", "parsing"]} | ||
walkdir = "2.3.2" | ||
geojson = {version = "0.24", features = ["geo-types"]} | ||
kml = "0.7.1" | ||
mp4iter = {git = "https://github.com/jenslar/mp4iter.git"} | ||
jpegiter = {git = "https://github.com/jenslar/jpegiter.git"} | ||
blake3 = "1.3.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The MIT License (MIT) | ||
Copyright © 2023 Jens Larsson, jens.dev@fastmail.com | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# gpmf-rs | ||
|
||
Rust crate for parsing GoPro GPMF data, directly from MP4, from "raw" GPMF-files extracted via ffmpeg, or byte slices. | ||
|
||
Example: | ||
```rs | ||
use gpmf_rs::Gpmf; | ||
use std::path::Path; | ||
|
||
fn main() -> std::io::Result<()> { | ||
let path = Path::new("GOPRO_VIDEO.MP4"); | ||
let gpmf = Gpmf::new(&path)?; | ||
println!("{gpmf:#?}"); | ||
Ok(()) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/// Stream type, mostly for internal use. | ||
/// This will have to be updated if new stream types are added or STNM free text descriptions change. | ||
#[derive(Debug, Clone)] | ||
pub enum DataType { | ||
/// Accelerometer | ||
Accelerometer, // Hero 7, 9 | ||
/// Accelerometer (up/down, right/left, forward/back) | ||
AccelerometerUrf, // Hero 5, 6 | ||
AgcAudioLevel, // Hero 9 | ||
AverageLuminance, // Hero 7 | ||
CameraOrientation, // Hero 9 | ||
ExposureTime, // Hero 7, 9 | ||
FaceCoordinates, // Hero 7, 9 | ||
Gps5, // Hero 5, 6, 7, 9, 10, 11 | ||
Gps9, // Hero 11 | ||
GravityVector, // Hero 9 | ||
Gyroscope, // Hero 7, 9 | ||
GyroscopeZxy, // Hero 5, 6 | ||
ImageUniformity, // Hero 7, 9 | ||
ImageOrientation, // Hero 9 | ||
LrvFrameSkip, // Hero 9 | ||
MicrophoneWet, // Hero 9 | ||
MrvFrameSkip, // Hero 9 | ||
PredominantHue, // Hero 7 | ||
SceneClassification, // Hero 7 | ||
SensorGain, // Fusion | ||
SensorIso, // Hero 7, 9 | ||
SensorReadOutTime, // Hero 7 | ||
WhiteBalanceRgbGains, // Hero 7, 9 | ||
WhiteBalanceTemperature, // Hero 7, 9 | ||
WindProcessing, // Hero 9 | ||
Other(String), | ||
} | ||
|
||
impl DataType { | ||
/// Returns stream name (`STNM`) specified in gpmf documentation as a string slice. | ||
pub fn to_str(&self) -> &str { | ||
match self { | ||
// Confirmed for Hero 7, 8, 9, 11 | ||
Self::Accelerometer => "Accelerometer", | ||
// Confirmed for Hero 5, 6 | ||
Self::AccelerometerUrf => "Accelerometer (up/down, right/left, forward/back)", | ||
// Confirmed for Hero 8, 9 (' ,' typo exists in GPMF) | ||
Self::AgcAudioLevel => "AGC audio level[rms_level ,peak_level]", | ||
// Confirmed for Hero 7 | ||
Self::AverageLuminance => "Average luminance", | ||
// Confirmed for Hero 9 | ||
Self::CameraOrientation => "CameraOrientation", | ||
// Confirmed for Hero 7, 9, Fusion | ||
Self::ExposureTime => "Exposure time (shutter speed)", | ||
// Confirmed for Hero 7, 9 | ||
Self::FaceCoordinates => "Face Coordinates and details", | ||
// Confirmed for Hero 5, 6, 7, 9, 10, Fusion | ||
Self::Gps5 => "GPS (Lat., Long., Alt., 2D speed, 3D speed)", | ||
// Confirmed for Hero 11 | ||
Self::Gps9 => "GPS (Lat., Long., Alt., 2D, 3D, days, secs, DOP, fix)", | ||
// Confirmed for Hero 9 | ||
Self::GravityVector => "Gravity Vector", | ||
// Confirmed for Hero 7, 9, 11. | ||
Self::Gyroscope => "Gyroscope", | ||
Self::GyroscopeZxy => "Gyroscope (z,x,y)", | ||
// Confirmed for Hero 7, 9 | ||
Self::ImageUniformity => "Image uniformity", | ||
// Confirmed for Hero 9 | ||
Self::ImageOrientation => "ImageOrientation", | ||
// Confirmed for Hero 9 | ||
Self::LrvFrameSkip => "LRV Frame Skip", | ||
// Confirmed for Hero 9 | ||
Self::MicrophoneWet => "Microphone Wet[mic_wet, all_mics, confidence]", | ||
// Confirmed for Hero 9 | ||
Self::MrvFrameSkip => "MRV Frame Skip", | ||
// Confirmed for Hero 7 | ||
Self::PredominantHue => "Predominant hue[[hue, weight], ...]", | ||
// Confirmed for Hero 7 | ||
Self::SceneClassification => "Scene classification[[CLASSIFIER_FOUR_CC,prob], ...]", | ||
// Confirmed for Fusion | ||
Self::SensorGain => "Sensor gain", | ||
// Confirmed for Hero 7, 9 | ||
Self::SensorIso => "Sensor ISO", | ||
// Confirmed for Hero 7 | ||
Self::SensorReadOutTime => "Sensor read out time", | ||
// Confirmed for Hero 7, 9 | ||
Self::WhiteBalanceRgbGains => "White Balance RGB gains", | ||
// Confirmed for Hero 7, 9 | ||
Self::WhiteBalanceTemperature => "White Balance temperature (Kelvin)", | ||
// Confirmed for Hero 9 | ||
Self::WindProcessing => "Wind Processing[wind_enable, meter_value(0 - 100)]", | ||
Self::Other(s) => s, | ||
} | ||
} | ||
|
||
/// Returns enum corresponding to stream name (`STNM`) specified in gpmf stream. | ||
/// If no results are returned despite the data being present, | ||
/// try using `Self::Other(String)` instead. Gpmf data can only be identified | ||
/// via its stream name free text description (`STNM`), which may differ between devices | ||
/// for the same kind of data. | ||
pub fn from_str(stream_type: &str) -> DataType { | ||
match stream_type { | ||
// Hero 7, 9 | Fusion | ||
"Accelerometer" => Self::Accelerometer, | ||
// Hero 5, 6 | ||
"Accelerometer (up/down, right/left, forward/back)" => Self::AccelerometerUrf, | ||
// Hero 9 (comma spacing is correct) | ||
"AGC audio level[rms_level ,peak_level]" => Self::AgcAudioLevel, | ||
// Hero 7 | ||
"Average luminance" => Self::AverageLuminance, | ||
// Hero 9 | ||
"CameraOrientation" => Self::CameraOrientation, | ||
// Hero 7, 9, Fusion | ||
"Exposure time (shutter speed)" => Self::ExposureTime, | ||
// Hero 7, 9 | ||
"Face Coordinates and details" => Self::FaceCoordinates, | ||
// Hero 7, 9 | ||
"GPS (Lat., Long., Alt., 2D speed, 3D speed)" => Self::Gps5, | ||
"GPS (Lat., Long., Alt., 2D, 3D, days, secs, DOP, fix)" => Self::Gps9, | ||
// Hero 9 | ||
"Gravity Vector" => Self::GravityVector, | ||
// Hero 7, 9 | Fusion | ||
"Gyroscope" => Self::Gyroscope, | ||
// Hero 5, 6 | ||
"Gyroscope (z,x,y)" => Self::GyroscopeZxy, | ||
// Hero 7, 9 | ||
"Image uniformity" => Self::ImageUniformity, | ||
// Hero 9 | ||
"ImageOrientation" => Self::ImageOrientation, | ||
// Hero 9 | ||
"LRV Frame Skip" => Self::LrvFrameSkip, | ||
// Hero 9 | ||
"Microphone Wet[mic_wet, all_mics, confidence]" => Self::MicrophoneWet, | ||
// Hero 9 | ||
"MRV Frame Skip" => Self::MrvFrameSkip, | ||
// Hero 7 | ||
"Predominant hue[[hue, weight], ...]" => Self::PredominantHue, | ||
// Hero 7 | ||
"Scene classification[[CLASSIFIER_FOUR_CC,prob], ...]" => Self::SceneClassification, | ||
// Fusion | ||
"Sensor gain (ISO x100)" => Self::SensorGain, | ||
// Hero 7, 9 | ||
"Sensor ISO" => Self::SensorIso, | ||
// Hero 7 | ||
"Sensor read out time" => Self::SensorReadOutTime, | ||
// Hero 7, 9 | ||
"White Balance RGB gains" => Self::WhiteBalanceRgbGains, | ||
// Hero 7, 9 | ||
"White Balance temperature (Kelvin)" => Self::WhiteBalanceTemperature, | ||
// Hero 9 | ||
"Wind Processing[wind_enable, meter_value(0 - 100)]" => Self::WindProcessing, | ||
// Other | ||
s => Self::Other(s.to_owned()), | ||
} | ||
} | ||
} |
Oops, something went wrong.