-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (25 loc) · 1.2 KB
/
Copy pathindex.js
File metadata and controls
33 lines (25 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fs = require('fs')
const getVideoMetaIndex = require('./src/get-video-meta-index')
const peelMetaStream = require('./src/peel-meta-stream')
const parseMetaFile = require('./src/parse-meta-file')
const args = {}
process.argv.slice(2).forEach((arg, i) => {
if (i % 2 === 0) args[arg.replace(/^-/, '')] = process.argv[i + 3]
})
const META_TYPE = 'gpmd'
const VIDEO_INPUT = `./data/${args.input}`
const META_OUTPUT = './data/01.bin'
const META_OUTPUT_JSON = './data/meta.json'
const logger = console;
(async () => {
const videoMetaIndex = await getVideoMetaIndex(VIDEO_INPUT, META_TYPE)
if (!videoMetaIndex) return logger.log('Put a GoPro video in the data folder!')
if (videoMetaIndex === -1) return logger.log(`No metadata stream found in the video ${VIDEO_INPUT}`)
logger.log(`Meta stream found at index ${videoMetaIndex}`)
logger.log(`Starting ffmpeg command to peel metadata from video ${VIDEO_INPUT}`)
await peelMetaStream(VIDEO_INPUT, videoMetaIndex, META_OUTPUT)
logger.log('Gps stream generated by ffmpeg file is ready to be parsed')
const meta = await parseMetaFile(META_OUTPUT)
fs.writeFileSync(META_OUTPUT_JSON, JSON.stringify(meta, null, 2))
logger.log('This is the end ...')
})()