@ -7,6 +7,7 @@ import { FaMapMarkerAlt } from 'react-icons/fa';
import { extractSrtGpsTrack } from './ffmpeg' ;
import { ReactSwal } from './swal' ;
import { handleError } from './util' ;
import { parseGpsLine } from './edlFormats' ;
export default async function tryShowGpsMap ( filePath : string , streamIndex : number ) {
@ -14,24 +15,16 @@ export default async function tryShowGpsMap(filePath: string, streamIndex: numbe
const subtitles = await extractSrtGpsTrack ( filePath , streamIndex ) ;
const gpsPoints = subtitles . flatMap ( ( subtitle ) = > {
const firstLine = subtitle . lines [ 0 ] ;
// example:
// "F/2.8, SS 776.89, ISO 100, EV -1.0, GPS (15.0732, 67.9771, 19), D 67.78m, H 20.30m, H.S 1.03m/s, V.S 0.00m/s"
const gpsMatch = firstLine ? . match ( /^\s*([^,]+),\s*SS\s+([^,]+),\s*ISO\s+([^,]+),\s*EV\s+([^,]+),\s*GPS\s+\(([^,]+),\s*([^,]+),\s*([^,]+)\),\s*D\s+([^m]+)m,\s*H\s+([^m]+)m,\s*H\.S\s+([^m]+)m\/s,\s*V\.S\s+([^m]+)m\/s\s*$/ ) ;
if ( ! gpsMatch || firstLine == null ) return [ ] ;
const { index } = subtitle ;
if ( firstLine == null || index == null ) return [ ] ;
const parsed = parseGpsLine ( firstLine ) ;
if ( parsed == null ) return [ ] ;
return [ {
index : subtitle.index ,
. . . parsed ,
index ,
raw : firstLine ,
f : gpsMatch [ 1 ] ! ,
ss : parseFloat ( gpsMatch ! [ 2 ] ! ) ,
iso : parseInt ( gpsMatch ! [ 3 ] ! , 10 ) ,
ev : parseFloat ( gpsMatch ! [ 4 ] ! ) ,
lat : parseFloat ( gpsMatch ! [ 5 ] ! ) ,
lng : parseFloat ( gpsMatch ! [ 6 ] ! ) ,
alt : parseFloat ( gpsMatch ! [ 7 ] ! ) ,
distance : parseFloat ( gpsMatch ! [ 8 ] ! ) ,
height : parseFloat ( gpsMatch ! [ 9 ] ! ) ,
horizontalSpeed : parseFloat ( gpsMatch ! [ 10 ] ! ) ,
verticalSpeed : parseFloat ( gpsMatch ! [ 11 ] ! ) ,
} ] ;
} ) ;
// console.log(gpsPoints)