DJI_SRT_Parser
Parses and interprets some data from DJI's Drones SRT metadata files.
Tested with Mavic Pro, Mavic 2 Zoom/Pro, Mavic 3, Mavic Mini, Mini 2, Mini SE, Air 2, Air 2s, DJI FPV, Phantom Pro (some versions), Inspire (some versions)...
You can send me your samples if you want them implemented.
Please let me know if you create something with this :).
Installation
Using npm:
$ npm install dji_srt_parser
Usage
let DJISRTParser = require('dji_srt_parser');
let fileName = 'filePath.SRT';
let dataString = readTextFile(fileName);
let DJIData = DJISRTParser(dataString, fileName);
let fileName2 = 'filePath2.SRT';
let dataString2 = readTextFile(fileName2);
let multi_DJIData = DJISRTParser(
[dataString, dataString2],
[fileName, filename2]
);
let geoJSON = DJIData.toGeoJSON();
console.log(DJIData.rawMetadata());
console.log(multi_DJIData.rawMetadata());
console.log(multi_DJIData.rawMetadata(filename2));
console.log(DJIData.metadata());
console.log(multi_DJIData.metadata(filename2));
console.log(multi_DJIData.metadata());
console.log(DJIData.getSmoothing());
console.log(DJIData.setSmoothing(0));
console.log(DJIData.getMillisecondsPerSamples());
console.log(DJIData.setMillisecondsPerSamples(0));
let obj = { customProperty: 'value', customProperty2: 123 };
console.log(DJIData.setProperties(obj));
console.log(DJIData.getFileName());
let csvData = DJIData.toCSV();
let mgjsonData = DJIData.toMGJSON();
let DJIData = DJISRTParser(
JSONDataString,
JSONfileName,
true
);
Smoothing is applied when interpreting the data because the GPS values provided by DJI are not accurate enough. They don't have enough digits. We average them with the surrounding values to create more pleasant paths and to be able to compute somewhat meaningful speeds. The interpreted values are not necessarily more accurate.
Units of interpreted data
(As far as we know)
- Timecode: HH:MM:SS,FFF
- GPS: degrees (and meters for third value, altitude)
- Date: timestamp in milliseconds (note that the time zone is not specified, could be local where the drone was registered, or flown...)
- Barometer: meters (more accurate than GPS altitude)
- Speed: km/h
- Duration: milliseconds
- Distance: meters
- ISO, shutter and EV (not always present)
How to use mgJSON files
I gathered some information on the mgJSON format in this repo: mgJSON
Contribution
Please make your changes to the dev branch, so that automated tests can be run before merging to master. Also, if possible, provide tests for new functionality.
Acknowledgements/credits
To-Do
- Add sample and tests for DJI FPV
- Fix disabled tests. Too strict, they fail with good changes
- Add tests for export formats