drone-path 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +13 -11
- package/app/ipc.d.mts +43 -0
- package/app/ipc.mjs +92 -54
- package/app/main.mjs +6 -6
- package/dist/appsession.js +17 -24
- package/dist/appstate.js +2 -1
- package/dist/buildinfo.js +9 -16
- package/dist/cammeta-decode.js +237 -0
- package/dist/cammeta.js +4 -242
- package/dist/cli.js +37 -11
- package/dist/config.js +181 -82
- package/dist/configfile.js +20 -7
- package/dist/errors.js +30 -0
- package/dist/exec-tool.js +13 -0
- package/dist/exportjob.js +7 -7
- package/dist/{fftools.js → ffmpeg-tools.js} +5 -4
- package/dist/{ff.js → ffmpeg.js} +12 -10
- package/dist/geo.js +1 -1
- package/dist/logging.js +1 -0
- package/dist/manual/build.js +5 -10
- package/dist/manual/cliref.js +4 -1
- package/dist/manual/reference.js +6 -11
- package/dist/{run.js → pipeline.js} +59 -39
- package/dist/{proto.js → protobuf-wire.js} +5 -5
- package/dist/range.js +3 -3
- package/dist/{page.js → render-page.js} +2 -2
- package/dist/render.js +5 -18
- package/dist/renderer/boot.js +2 -2
- package/dist/renderer/dom.js +32 -10
- package/dist/renderer/scene.js +14 -6
- package/dist/restyle.js +1 -1
- package/dist/serve.js +1 -31
- package/dist/srt.js +2 -2
- package/dist/telemetry-json-schema.js +6 -11
- package/dist/telemetry-json.js +13 -0
- package/dist/telemetry-math.js +1 -1
- package/dist/{summary.js → telemetry-summary.js} +4 -4
- package/dist/telemetry.js +16 -6
- package/dist/track-format.js +13 -0
- package/dist/track-geojson.js +44 -0
- package/dist/track-gpx.js +34 -0
- package/dist/track-kml.js +47 -0
- package/dist/track-kmz.js +68 -0
- package/dist/track-write.js +41 -0
- package/dist/track.js +79 -0
- package/package.json +8 -8
- /package/dist/{inputs.js → recordings.js} +0 -0
package/dist/exportjob.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { errorMessage } from './errors.js';
|
|
3
|
+
import { ERR_COULD_NOT_REPLACE, ERR_EXPORT_ALREADY_RUNNING, ERR_OUTPUT_OVERWRITES_SOURCE, ERR_OUTPUT_PATH_ABSOLUTE, ERR_RENDER_KEPT_AT, errorMessage, } from './errors.js';
|
|
4
4
|
import { samePath, uniquePath } from './paths.js';
|
|
5
|
-
import { processRecording } from './
|
|
5
|
+
import { processRecording } from './pipeline.js';
|
|
6
6
|
const runViaPipeline = (deps) => (videoPath, request, log, workingPath, signal, onCapture) => processRecording(videoPath, request.config, log, workingPath, {
|
|
7
7
|
range: request.range ?? undefined,
|
|
8
8
|
signal,
|
|
@@ -28,8 +28,8 @@ function swapIntoPlace(working, outPath) {
|
|
|
28
28
|
fs.renameSync(working, outPath);
|
|
29
29
|
}
|
|
30
30
|
catch (e) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
`(
|
|
31
|
+
throw new Error(`${ERR_COULD_NOT_REPLACE}${outPath}: ${errorMessage(e)} ` +
|
|
32
|
+
`(${ERR_RENDER_KEPT_AT}${working})`, { cause: e });
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
export function createExportRunner(options) {
|
|
@@ -59,12 +59,12 @@ export function createExportRunner(options) {
|
|
|
59
59
|
return {
|
|
60
60
|
start(videoPath, request) {
|
|
61
61
|
if (job)
|
|
62
|
-
throw new Error(
|
|
62
|
+
throw new Error(ERR_EXPORT_ALREADY_RUNNING);
|
|
63
63
|
if (!path.isAbsolute(request.outPath)) {
|
|
64
|
-
throw new Error(
|
|
64
|
+
throw new Error(`${ERR_OUTPUT_PATH_ABSOLUTE}${request.outPath}`);
|
|
65
65
|
}
|
|
66
66
|
if (samePath(request.outPath, videoPath)) {
|
|
67
|
-
throw new Error(
|
|
67
|
+
throw new Error(ERR_OUTPUT_OVERWRITES_SOURCE);
|
|
68
68
|
}
|
|
69
69
|
const controller = new AbortController();
|
|
70
70
|
job = { abort: () => controller.abort() };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
export const FFMPEG_TOOL_NAMES = ['ffmpeg', 'ffprobe'];
|
|
4
5
|
function isPathLike(value) {
|
|
5
6
|
return value.includes('/') || value.includes('\\') || path.isAbsolute(value);
|
|
6
7
|
}
|
|
7
|
-
export function
|
|
8
|
+
export function pickFfmpegTool(tool, override, candidates, exists) {
|
|
8
9
|
if (override) {
|
|
9
10
|
if (isPathLike(override) && !exists(override)) {
|
|
10
11
|
throw new Error(`invalid ${tool} override (CLI --${tool} or config key \`${tool}\`): no such file: ${override}`);
|
|
@@ -47,9 +48,9 @@ function realEnv() {
|
|
|
47
48
|
candidates: (tool) => [packagedCandidate(tool), devCandidate(tool)],
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
|
-
export function
|
|
51
|
+
export function resolveFfmpegTools(overrides, env = realEnv()) {
|
|
51
52
|
return {
|
|
52
|
-
ffmpeg:
|
|
53
|
-
ffprobe:
|
|
53
|
+
ffmpeg: pickFfmpegTool('ffmpeg', overrides.ffmpeg, env.candidates('ffmpeg'), env.exists),
|
|
54
|
+
ffprobe: pickFfmpegTool('ffprobe', overrides.ffprobe, env.candidates('ffprobe'), env.exists),
|
|
54
55
|
};
|
|
55
56
|
}
|
package/dist/{ff.js → ffmpeg.js}
RENAMED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ERR_NO_FRAME_RATE } from './errors.js';
|
|
2
|
+
import { runTool } from './exec-tool.js';
|
|
3
3
|
import { framesForSeconds, parseFpsRate, parseRate } from './frametime.js';
|
|
4
|
-
|
|
4
|
+
import { FFMPEG_TOOL_NAMES } from './ffmpeg-tools.js';
|
|
5
5
|
const INSTALL_HINT = 'point --ffmpeg/--ffprobe at your executables, or install ffmpeg (includes ' +
|
|
6
6
|
'ffprobe) and make sure both are on PATH, e.g. "winget install Gyan.FFmpeg" ' +
|
|
7
7
|
'(Windows), "brew install ffmpeg" (macOS) or "apt install ffmpeg" (Linux)';
|
|
8
8
|
const FFPROBE_MAX_BUFFER = 64 * 1024 * 1024;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const TOOL_VERSION_MAX_BUFFER = 1 << 20;
|
|
10
|
+
const RATE_PROBE_MAX_BUFFER = 1 << 20;
|
|
11
|
+
export async function requireFfmpegTools(tools) {
|
|
12
|
+
for (const tool of FFMPEG_TOOL_NAMES) {
|
|
11
13
|
const command = tools[tool];
|
|
12
14
|
try {
|
|
13
|
-
await
|
|
15
|
+
await runTool(command, ['-version'], { maxBuffer: TOOL_VERSION_MAX_BUFFER });
|
|
14
16
|
}
|
|
15
17
|
catch (e) {
|
|
16
18
|
throw new Error(`${tool} is required but could not be run (${command}) - ${INSTALL_HINT}`, { cause: e });
|
|
@@ -18,7 +20,7 @@ export async function requireTools(tools) {
|
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
export async function ffprobeJson(tools, videoPath, args) {
|
|
21
|
-
const { stdout } = await
|
|
23
|
+
const { stdout } = await runTool(tools.ffprobe, ['-v', 'error', ...args, videoPath], { maxBuffer: FFPROBE_MAX_BUFFER });
|
|
22
24
|
return JSON.parse(stdout || '{}');
|
|
23
25
|
}
|
|
24
26
|
function parseCount(text) {
|
|
@@ -39,7 +41,7 @@ export async function probeVideo(tools, videoPath, log = () => { }) {
|
|
|
39
41
|
const fps = parseFpsRate(stream.r_frame_rate) ??
|
|
40
42
|
parseFpsRate(stream.avg_frame_rate);
|
|
41
43
|
if (!fps)
|
|
42
|
-
throw new Error(
|
|
44
|
+
throw new Error(ERR_NO_FRAME_RATE);
|
|
43
45
|
const durationSec = Number.parseFloat(format.duration ?? '');
|
|
44
46
|
let frames = parseCount(stream.nb_frames);
|
|
45
47
|
if (!Number.isFinite(frames) || frames <= 0) {
|
|
@@ -77,11 +79,11 @@ export async function verifyOutput(tools, outPath, frames, fpsValue) {
|
|
|
77
79
|
};
|
|
78
80
|
}
|
|
79
81
|
async function probeRateFrames(ffprobe, file) {
|
|
80
|
-
const { stdout } = await
|
|
82
|
+
const { stdout } = await runTool(ffprobe, [
|
|
81
83
|
'-v', 'error', '-select_streams', 'v:0',
|
|
82
84
|
'-show_entries', 'stream=avg_frame_rate,nb_frames',
|
|
83
85
|
'-of', 'csv=p=0', '--', file,
|
|
84
|
-
], { maxBuffer:
|
|
86
|
+
], { maxBuffer: RATE_PROBE_MAX_BUFFER });
|
|
85
87
|
return stdout.trim();
|
|
86
88
|
}
|
|
87
89
|
export async function outputMatchesSource(tools, src, out) {
|
package/dist/geo.js
CHANGED
|
@@ -11,7 +11,7 @@ export function isGpsFix(lat, lon) {
|
|
|
11
11
|
lon < 180 &&
|
|
12
12
|
!(lat === 0 && lon === 0));
|
|
13
13
|
}
|
|
14
|
-
export function
|
|
14
|
+
export function gpsFixOrNull(lat, lon) {
|
|
15
15
|
return lat !== null && lon !== null && isGpsFix(lat, lon) ? { lat, lon } : null;
|
|
16
16
|
}
|
|
17
17
|
export function haversineM(a, b) {
|
package/dist/logging.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/manual/build.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { runToolMain } from '../errors.js';
|
|
4
5
|
import { compileMarkdown } from './markdown.js';
|
|
5
6
|
import { bundleModuleSource } from './module.js';
|
|
6
7
|
import { navFromIndex } from './nav.js';
|
|
@@ -57,16 +58,10 @@ export function buildManual(paths) {
|
|
|
57
58
|
return { pages: compiled.length, images: referenced };
|
|
58
59
|
}
|
|
59
60
|
function main() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
process.stderr.write(`[drone-path] manual: ${result.pages} page(s), ${result.images.length} image(s)\n`);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
process.stderr.write(`[drone-path] ERROR: ${e.message}\n`);
|
|
67
|
-
process.exitCode = 1;
|
|
68
|
-
}
|
|
61
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
62
|
+
const result = buildManual(defaultManualPaths(root));
|
|
63
|
+
process.stderr.write(`[drone-path] manual: ${result.pages} page(s), ${result.images.length} image(s)\n`);
|
|
69
64
|
}
|
|
70
65
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
71
|
-
main
|
|
66
|
+
void runToolMain(main);
|
|
72
67
|
}
|
package/dist/manual/cliref.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONFIG_FILE_OPTION, CONFIG_OPTIONS, cliDefaultOf } from '../config.js';
|
|
1
|
+
import { CONFIG_FILE_OPTION, CONFIG_OPTIONS, TELEMETRY_JSON_ALIAS, cliDefaultOf, } from '../config.js';
|
|
2
2
|
function defaultCell(key) {
|
|
3
3
|
const value = cliDefaultOf(key);
|
|
4
4
|
if (typeof value === 'boolean')
|
|
@@ -12,6 +12,9 @@ function describe(row) {
|
|
|
12
12
|
export function generateCliReference() {
|
|
13
13
|
const rows = CONFIG_OPTIONS.map((row) => `| \`${row.key}\` | \`${row.cli.flags}\` | ${defaultCell(row.key)} | ${describe(row)} |`);
|
|
14
14
|
rows.push(`| — | \`${CONFIG_FILE_OPTION.flags}\` | — | ${CONFIG_FILE_OPTION.help} |`);
|
|
15
|
+
rows.push(`| \`${TELEMETRY_JSON_ALIAS.inputKey}\` | \`${TELEMETRY_JSON_ALIAS.flags}\` | — | ` +
|
|
16
|
+
`deprecated alias of --track-out <file>.json: same output, warns on use, ` +
|
|
17
|
+
`removed in a future version |`);
|
|
15
18
|
return [
|
|
16
19
|
'<!-- Generated from the option vocabulary in src/config.ts by "npm run docs:reference". Do not edit by hand. -->',
|
|
17
20
|
'',
|
package/dist/manual/reference.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { runToolMain } from '../errors.js';
|
|
4
5
|
import { generateCliReference } from './cliref.js';
|
|
5
6
|
function writeReference(file) {
|
|
6
7
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
7
8
|
fs.writeFileSync(file, generateCliReference());
|
|
8
9
|
}
|
|
9
10
|
function main() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
process.stderr.write(`[drone-path] manual: wrote ${path.relative(root, file)}\n`);
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
process.stderr.write(`[drone-path] ERROR: ${e.message}\n`);
|
|
18
|
-
process.exitCode = 1;
|
|
19
|
-
}
|
|
11
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
12
|
+
const file = path.join(root, 'docs', 'user', 'cli-reference.md');
|
|
13
|
+
writeReference(file);
|
|
14
|
+
process.stderr.write(`[drone-path] manual: wrote ${path.relative(root, file)}\n`);
|
|
20
15
|
}
|
|
21
16
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
22
|
-
main
|
|
17
|
+
void runToolMain(main);
|
|
23
18
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { errorMessage } from './errors.js';
|
|
4
|
-
import { outputMatchesSource, probeVideo, verifyOutput } from './
|
|
5
|
-
import {
|
|
6
|
-
import { videoBaseName } from './
|
|
3
|
+
import { ERR_OUTPUT_VERIFICATION, ERR_RENDER_CANCELED, errorMessage } from './errors.js';
|
|
4
|
+
import { outputMatchesSource, probeVideo, verifyOutput } from './ffmpeg.js';
|
|
5
|
+
import { resolveFfmpegTools } from './ffmpeg-tools.js';
|
|
6
|
+
import { videoBaseName } from './recordings.js';
|
|
7
7
|
import { pathKey, uniquePath } from './paths.js';
|
|
8
8
|
import { loadTelemetry } from './telemetry.js';
|
|
9
|
-
import {
|
|
9
|
+
import { writeTrackFile } from './track-write.js';
|
|
10
10
|
import { prefetchTiles } from './tiles.js';
|
|
11
11
|
import { planIntroOutroFrames, planView } from './plan.js';
|
|
12
|
-
import { buildPageHtml, planPageOpts } from './page.js';
|
|
12
|
+
import { buildPageHtml, planPageOpts } from './render-page.js';
|
|
13
13
|
import { renderVideo } from './render.js';
|
|
14
|
-
import { effectiveZoomOut, hasAltitude,
|
|
15
|
-
import {
|
|
14
|
+
import { effectiveZoomOut, hasAltitude, resolveHudLayout, resolveFrameRange, } from './config.js';
|
|
15
|
+
import { fixCountLabel, noLockCountLabel, telemetrySummary, trackDistanceLabel, } from './telemetry-summary.js';
|
|
16
16
|
const PREPARE_STAGE_ORDER = ['probe', 'telemetry', 'plan'];
|
|
17
17
|
export function outputPathFor(videoPath, config) {
|
|
18
18
|
const base = videoBaseName(videoPath);
|
|
@@ -38,13 +38,13 @@ export function planOutputs(videos, config) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
function resolveHud(config, tel, log) {
|
|
41
|
-
const hud =
|
|
41
|
+
const hud = resolveHudLayout(config.hud, hasAltitude(tel.frames.map((f) => f.alt)));
|
|
42
42
|
if (config.hud.alt && !hud.alt) {
|
|
43
43
|
log('hud: altitude unavailable in this telemetry source (chip disabled)');
|
|
44
44
|
}
|
|
45
45
|
return hud;
|
|
46
46
|
}
|
|
47
|
-
export function
|
|
47
|
+
export function frameChannelsOf(tel) {
|
|
48
48
|
const lat = [];
|
|
49
49
|
const lon = [];
|
|
50
50
|
tel.frames.forEach((frame, i) => {
|
|
@@ -141,13 +141,14 @@ async function telemetryStage(env, probe) {
|
|
|
141
141
|
});
|
|
142
142
|
const tel = loaded.telemetry;
|
|
143
143
|
const summary = telemetrySummary(tel);
|
|
144
|
-
log(`telemetry: ${summary.source} (${summary.method}), ${
|
|
144
|
+
log(`telemetry: ${summary.source} (${summary.method}), ${fixCountLabel(summary.fixCount)}, ` +
|
|
145
145
|
`heading=${summary.headingMode}, track ${trackDistanceLabel(summary.trackDistanceM)}` +
|
|
146
|
-
(summary.noLock ? `, ${
|
|
146
|
+
(summary.noLock ? `, ${noLockCountLabel(summary.noLock)}` : ''));
|
|
147
147
|
const hud = resolveHud(config, tel, log);
|
|
148
148
|
return {
|
|
149
149
|
tel,
|
|
150
150
|
frameValues: loaded.frameValues,
|
|
151
|
+
trackValues: loaded.trackValues,
|
|
151
152
|
protoFile: loaded.protoFile,
|
|
152
153
|
gimbalDevice: loaded.gimbalDevice,
|
|
153
154
|
hud,
|
|
@@ -177,20 +178,21 @@ export async function prepareSession(videoPath, config, log, options = {}) {
|
|
|
177
178
|
config,
|
|
178
179
|
log,
|
|
179
180
|
deps: resolveDeps(options.deps, config.tileCache),
|
|
180
|
-
tools: options.tools ??
|
|
181
|
+
tools: options.tools ?? resolveFfmpegTools(config),
|
|
181
182
|
report: createPrepareReporter(options.onProgress),
|
|
182
183
|
};
|
|
183
184
|
const { width, height } = config;
|
|
184
185
|
const { probe, introOutro } = await probeStage(env);
|
|
185
|
-
const { tel, frameValues, protoFile, gimbalDevice, hud } = await telemetryStage(env, probe);
|
|
186
|
+
const { tel, frameValues, trackValues, protoFile, gimbalDevice, hud } = await telemetryStage(env, probe);
|
|
186
187
|
const overview = await viewPlanStage(env, tel);
|
|
187
|
-
const frames =
|
|
188
|
+
const frames = frameChannelsOf(tel);
|
|
188
189
|
return {
|
|
189
190
|
width,
|
|
190
191
|
height,
|
|
191
192
|
probe,
|
|
192
193
|
tel,
|
|
193
194
|
frameValues,
|
|
195
|
+
trackValues,
|
|
194
196
|
protoFile,
|
|
195
197
|
gimbalDevice,
|
|
196
198
|
hud,
|
|
@@ -232,7 +234,7 @@ function buildOkSummary(ctx, elapsedSec) {
|
|
|
232
234
|
source: telemetry.source,
|
|
233
235
|
method: telemetry.method,
|
|
234
236
|
headingMode: telemetry.headingMode,
|
|
235
|
-
fixes: telemetry.
|
|
237
|
+
fixes: telemetry.fixCount,
|
|
236
238
|
noLock: telemetry.noLock,
|
|
237
239
|
trackDistanceM: telemetry.trackDistanceM,
|
|
238
240
|
frames: ctx.outFrames,
|
|
@@ -251,7 +253,7 @@ async function verifyRenderedOutput(env) {
|
|
|
251
253
|
const { ctx, deps, tools } = env;
|
|
252
254
|
const verify = await deps.verifyOutput(tools, ctx.outPath, ctx.outFrames, ctx.probe.fps.value);
|
|
253
255
|
if (!verify.ok) {
|
|
254
|
-
throw new Error(
|
|
256
|
+
throw new Error(`${ERR_OUTPUT_VERIFICATION}got ${verify.frames} frames @ ${verify.fps ?? 'unknown'}, ` +
|
|
255
257
|
`expected ${ctx.outFrames} @ ${ctx.probe.fps.str}`);
|
|
256
258
|
}
|
|
257
259
|
ctx.log(ctx.frameRange
|
|
@@ -298,28 +300,38 @@ export function telemetryExportInput(prep) {
|
|
|
298
300
|
headingDeg: prep.tel.frames.map((frame) => frame.headingDeg),
|
|
299
301
|
};
|
|
300
302
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
+
// The track formats read the fix-faithful records (which carry positions and
|
|
304
|
+
// source times for every telemetry source); the .json document keeps its own
|
|
305
|
+
// record stream.
|
|
306
|
+
export function trackExportStream(prep) {
|
|
307
|
+
return {
|
|
308
|
+
records: prep.trackValues,
|
|
309
|
+
fpsValue: prep.probe.fps.value,
|
|
310
|
+
frameCount: prep.probe.frames,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function writeTrackExport(file, prep, log) {
|
|
314
|
+
// The export intentionally covers the whole recording: a frame range
|
|
303
315
|
// limits the render, never this export.
|
|
304
|
-
|
|
305
|
-
log(`
|
|
316
|
+
writeTrackFile(file, { document: telemetryExportInput(prep), track: trackExportStream(prep) }, null);
|
|
317
|
+
log(`track: wrote ${file}`);
|
|
306
318
|
}
|
|
307
319
|
export async function processRecording(videoPath, config, log, outPath = outputPathFor(videoPath, config), options = {}) {
|
|
308
320
|
const t0 = Date.now();
|
|
309
321
|
const deps = resolveDeps(options.deps, config.tileCache);
|
|
310
|
-
const tools = options.tools ??
|
|
322
|
+
const tools = options.tools ?? resolveFfmpegTools(config);
|
|
311
323
|
if (options.signal?.aborted)
|
|
312
|
-
throw new Error(
|
|
324
|
+
throw new Error(ERR_RENDER_CANCELED);
|
|
313
325
|
const prep = await prepareSession(videoPath, config, log, {
|
|
314
326
|
...options,
|
|
315
327
|
deps,
|
|
316
328
|
tools,
|
|
317
329
|
});
|
|
318
|
-
if (config.
|
|
319
|
-
|
|
330
|
+
if (config.trackOut) {
|
|
331
|
+
writeTrackExport(config.trackOut, prep, log);
|
|
320
332
|
}
|
|
321
333
|
const tileStats = await tileWarmStage(deps, config, prep.overview, log);
|
|
322
|
-
const range =
|
|
334
|
+
const range = resolveFrameRange(options.range, prep.probe.frames);
|
|
323
335
|
const outFrames = range ? range.end - range.start + 1 : prep.probe.frames;
|
|
324
336
|
const ctx = {
|
|
325
337
|
...prep,
|
|
@@ -337,30 +349,38 @@ export async function processRecording(videoPath, config, log, outPath = outputP
|
|
|
337
349
|
export async function runBatch(videos, config, log, emit, options = {}) {
|
|
338
350
|
const result = { ok: 0, skipped: 0, failed: 0 };
|
|
339
351
|
const deps = resolveDeps(options.deps, config.tileCache);
|
|
340
|
-
const tools = options.tools ??
|
|
341
|
-
if (config.
|
|
342
|
-
throw new Error('--
|
|
352
|
+
const tools = options.tools ?? resolveFfmpegTools(config);
|
|
353
|
+
if (config.trackOut && videos.length > 1) {
|
|
354
|
+
throw new Error('--track-out writes one file per run: give a single recording');
|
|
343
355
|
}
|
|
344
356
|
const plans = planOutputs(videos, config);
|
|
357
|
+
function collisionWarning(base, plan) {
|
|
358
|
+
if (plan.out !== plan.plain) {
|
|
359
|
+
log(`warning: output name collision for ${base} - writing ${path.basename(plan.out)} instead`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
async function maybeSkip(video, plan) {
|
|
363
|
+
if (!(config.skipExisting && (await deps.outputMatchesSource(tools, video, plan.out)))) {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
log(`SKIP ${plan.out} (exists and matches the source)`);
|
|
367
|
+
return 'skipped';
|
|
368
|
+
}
|
|
369
|
+
async function runOne(video, plan) {
|
|
370
|
+
return processRecording(video, config, log, plan.out, { ...options, deps, tools });
|
|
371
|
+
}
|
|
345
372
|
for (const [idx, video] of videos.entries()) {
|
|
346
373
|
const base = path.basename(video);
|
|
347
374
|
log(`=== ${base} ===`);
|
|
348
375
|
const plan = plans[idx];
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
if (config.skipExisting && (await deps.outputMatchesSource(tools, video, plan.out))) {
|
|
353
|
-
log(`SKIP ${plan.out} (exists and matches the source)`);
|
|
376
|
+
collisionWarning(base, plan);
|
|
377
|
+
if ((await maybeSkip(video, plan)) !== null) {
|
|
354
378
|
emit({ video, out: plan.out, status: 'skipped', elapsedSec: 0 });
|
|
355
379
|
result.skipped++;
|
|
356
380
|
continue;
|
|
357
381
|
}
|
|
358
382
|
try {
|
|
359
|
-
const summary = await
|
|
360
|
-
...options,
|
|
361
|
-
deps,
|
|
362
|
-
tools,
|
|
363
|
-
});
|
|
383
|
+
const summary = await runOne(video, plan);
|
|
364
384
|
emit(summary);
|
|
365
385
|
log(`OK ${plan.out} (${summary.frames} frames @ ${summary.fps}, ${summary.elapsedSec} s)`);
|
|
366
386
|
result.ok++;
|
|
@@ -77,26 +77,26 @@ function pushField(fields, fieldNumber, field) {
|
|
|
77
77
|
else
|
|
78
78
|
fields.set(fieldNumber, [field]);
|
|
79
79
|
}
|
|
80
|
-
export function
|
|
80
|
+
export function firstSubMessage(buf, fields, fieldNumber) {
|
|
81
81
|
const field = fields.get(fieldNumber)?.[0];
|
|
82
82
|
if (!field?.bytesSpan)
|
|
83
83
|
return null;
|
|
84
84
|
const [start, end] = field.bytesSpan;
|
|
85
85
|
return parseProtoFields(buf, start, end);
|
|
86
86
|
}
|
|
87
|
-
export function
|
|
87
|
+
export function firstVarintField(fields, fieldNumber) {
|
|
88
88
|
const value = fields.get(fieldNumber)?.[0]?.varintValue;
|
|
89
89
|
return value !== undefined ? signedVarint(value) : null;
|
|
90
90
|
}
|
|
91
|
-
export function
|
|
91
|
+
export function firstFloatField(fields, fieldNumber) {
|
|
92
92
|
const value = fields.get(fieldNumber)?.[0]?.floatValue;
|
|
93
93
|
return value ?? null;
|
|
94
94
|
}
|
|
95
|
-
export function
|
|
95
|
+
export function firstDoubleField(fields, fieldNumber) {
|
|
96
96
|
const value = fields.get(fieldNumber)?.[0]?.doubleValue;
|
|
97
97
|
return value ?? null;
|
|
98
98
|
}
|
|
99
|
-
export function
|
|
99
|
+
export function firstStringField(buf, fields, fieldNumber) {
|
|
100
100
|
const span = fields.get(fieldNumber)?.[0]?.bytesSpan;
|
|
101
101
|
return span ? buf.toString('utf8', span[0], span[1]) : null;
|
|
102
102
|
}
|
package/dist/range.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function parseByteRange(header, size) {
|
|
2
2
|
if (header === undefined)
|
|
3
3
|
return null;
|
|
4
4
|
const text = Array.isArray(header) ? header[0] : header;
|
|
@@ -28,8 +28,8 @@ export function parseRange(header, size) {
|
|
|
28
28
|
return 'unsatisfiable';
|
|
29
29
|
return { start, end: Math.min(end, size - 1) };
|
|
30
30
|
}
|
|
31
|
-
export function
|
|
32
|
-
const range =
|
|
31
|
+
export function planByteRange(header, size, mime) {
|
|
32
|
+
const range = parseByteRange(header, size);
|
|
33
33
|
if (range === 'unsatisfiable') {
|
|
34
34
|
return {
|
|
35
35
|
status: 416,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hasAltitude,
|
|
1
|
+
import { hasAltitude, resolveHudLayout } from './config.js';
|
|
2
2
|
import { decimateTrack } from './decimate.js';
|
|
3
3
|
import { unproject } from './geo.js';
|
|
4
4
|
import { planIntroOutroFrames, planView } from './plan.js';
|
|
@@ -7,7 +7,7 @@ export function planPageOpts(opts) {
|
|
|
7
7
|
const { bbox, width, height, config, source, frames, planned, previous } = opts;
|
|
8
8
|
const overview = planned?.overview ?? planView(bbox, width, height, config);
|
|
9
9
|
const introOutro = planned?.introOutro ?? planIntroOutroFrames(config, source);
|
|
10
|
-
const hud = planned?.hud ??
|
|
10
|
+
const hud = planned?.hud ?? resolveHudLayout(config.hud, hasAltitude(frames.alt));
|
|
11
11
|
const decimated = previous && previous.zoom === overview.zoom
|
|
12
12
|
? previous.decimated
|
|
13
13
|
: decimateTrack(frames.lat, frames.lon, overview.zoom);
|
package/dist/render.js
CHANGED
|
@@ -2,7 +2,7 @@ import http from 'node:http';
|
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import { once } from 'node:events';
|
|
4
4
|
import { MIME } from './assets.js';
|
|
5
|
-
import { errorMessage } from './errors.js';
|
|
5
|
+
import { ERR_RENDER_CANCELED, errorMessage } from './errors.js';
|
|
6
6
|
import { RENDERER_DIR, serveAsset } from './serve.js';
|
|
7
7
|
const PAGE_LOAD_TIMEOUT_MS = 60000;
|
|
8
8
|
const SCREENSHOT_TIMEOUT_MS = 60000;
|
|
@@ -167,7 +167,7 @@ async function workerLoop(run, loop, workerId) {
|
|
|
167
167
|
if (loop.failed)
|
|
168
168
|
return;
|
|
169
169
|
if (run.signal?.aborted)
|
|
170
|
-
throw new Error(
|
|
170
|
+
throw new Error(ERR_RENDER_CANCELED);
|
|
171
171
|
const idx = loop.cursor++;
|
|
172
172
|
if (idx >= run.frames)
|
|
173
173
|
break;
|
|
@@ -204,26 +204,13 @@ function formatProfile(profile, workerCount) {
|
|
|
204
204
|
}
|
|
205
205
|
async function captureAndEncode(active, env) {
|
|
206
206
|
const { ctx, url, timing, workerCount } = env;
|
|
207
|
-
const { fpsStr, codec, quality, preset, outPath, signal,
|
|
207
|
+
const { fpsStr, codec, quality, preset, outPath, signal, log, tools } = ctx;
|
|
208
208
|
const encoder = spawnEncoder(tools.ffmpeg, fpsStr, { codec, quality, preset }, outPath);
|
|
209
209
|
const killOnAbort = () => encoder.kill();
|
|
210
210
|
signal?.addEventListener('abort', killOnAbort, { once: true });
|
|
211
211
|
const stream = new OrderedFrameStream(encoder);
|
|
212
212
|
try {
|
|
213
|
-
await runWorkers({
|
|
214
|
-
active,
|
|
215
|
-
url,
|
|
216
|
-
width,
|
|
217
|
-
height,
|
|
218
|
-
frames,
|
|
219
|
-
frameStart,
|
|
220
|
-
capture,
|
|
221
|
-
signal,
|
|
222
|
-
log,
|
|
223
|
-
onCapture,
|
|
224
|
-
stream,
|
|
225
|
-
timing,
|
|
226
|
-
}, workerCount);
|
|
213
|
+
await runWorkers({ ...ctx, active, url, stream, timing }, workerCount);
|
|
227
214
|
await finishEncode(encoder, stream, log, outPath);
|
|
228
215
|
}
|
|
229
216
|
catch (e) {
|
|
@@ -264,7 +251,7 @@ export async function renderVideo(opts) {
|
|
|
264
251
|
tools,
|
|
265
252
|
};
|
|
266
253
|
if (signal?.aborted)
|
|
267
|
-
throw new Error(
|
|
254
|
+
throw new Error(ERR_RENDER_CANCELED);
|
|
268
255
|
const timing = { evalMs: 0, captureMs: 0, emitMs: 0 };
|
|
269
256
|
const { server, url } = await startServer({ html, style, tileCache });
|
|
270
257
|
const env = { ctx, url, timing, workerCount };
|
package/dist/renderer/boot.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createScene } from './scene.js';
|
|
2
|
-
export function bootScene(host, data, L) {
|
|
3
|
-
const scene = createScene(host, data, { L });
|
|
2
|
+
export function bootScene(host, data, L, opts) {
|
|
3
|
+
const scene = createScene(host, data, { L, hudHost: opts?.hudHost });
|
|
4
4
|
// The pane size may only settle after creation; re-measure post-layout.
|
|
5
5
|
requestAnimationFrame(() => scene.relayout());
|
|
6
6
|
return scene;
|
package/dist/renderer/dom.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const at = `.${scope}`;
|
|
1
|
+
function mapCss(at, src, theme, width, height) {
|
|
3
2
|
return `
|
|
4
3
|
${at} { margin: 0; padding: 0; overflow: hidden; background: ${src.bg}; }
|
|
5
4
|
${at}, ${at} * { animation: none !important; transition: none !important; }
|
|
@@ -17,7 +16,10 @@ export function sceneCss(src, theme, width, height, scale, scope) {
|
|
|
17
16
|
position: absolute; inset: 0; z-index: 500; pointer-events: none;
|
|
18
17
|
background: radial-gradient(ellipse 78% 78% at 50% 44%,
|
|
19
18
|
rgba(0,0,0,0) 52%, rgba(0,0,0,${theme.vignette}) 100%);
|
|
20
|
-
}
|
|
19
|
+
}`;
|
|
20
|
+
}
|
|
21
|
+
function droneCss(at, theme, scale) {
|
|
22
|
+
return `
|
|
21
23
|
${at} .drone-wrap {
|
|
22
24
|
width: ${Math.round(46 * scale)}px; height: ${Math.round(46 * scale)}px;
|
|
23
25
|
border-radius: 50%;
|
|
@@ -30,7 +32,10 @@ export function sceneCss(src, theme, width, height, scale, scope) {
|
|
|
30
32
|
box-sizing: border-box;
|
|
31
33
|
}
|
|
32
34
|
${at} .drone-arrow { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
|
|
33
|
-
${at} .drone-arrow svg { width: 72%; height: 72%; display: block; }
|
|
35
|
+
${at} .drone-arrow svg { width: 72%; height: 72%; display: block; }`;
|
|
36
|
+
}
|
|
37
|
+
function chipCss(at, theme, scale) {
|
|
38
|
+
return `
|
|
34
39
|
${at} #hud {
|
|
35
40
|
position: absolute; top: ${Math.round(16 * scale)}px; left: ${Math.round(16 * scale)}px;
|
|
36
41
|
display: flex; flex-direction: column; gap: ${Math.round(8 * scale)}px;
|
|
@@ -59,7 +64,10 @@ export function sceneCss(src, theme, width, height, scale, scope) {
|
|
|
59
64
|
font-size: 0.55em; font-weight: 700; letter-spacing: 1.2px;
|
|
60
65
|
color: ${theme.core}; opacity: 0.95;
|
|
61
66
|
}
|
|
62
|
-
${at} .chip .unit { font-weight: 500; opacity: 0.72; font-size: 0.68em; }
|
|
67
|
+
${at} .chip .unit { font-weight: 500; opacity: 0.72; font-size: 0.68em; }`;
|
|
68
|
+
}
|
|
69
|
+
function attrCss(at, scale) {
|
|
70
|
+
return `
|
|
63
71
|
${at} #attr {
|
|
64
72
|
position: absolute; right: 0; bottom: 0; z-index: 1000; max-width: 72%;
|
|
65
73
|
background: rgba(12, 14, 22, 0.62); color: rgba(255,255,255,0.78);
|
|
@@ -69,7 +77,10 @@ export function sceneCss(src, theme, width, height, scale, scope) {
|
|
|
69
77
|
border-radius: ${Math.round(4 * scale)}px 0 0 0;
|
|
70
78
|
pointer-events: none;
|
|
71
79
|
}
|
|
72
|
-
${at} #attr a { color: rgba(255,255,255,0.92); text-decoration: none; }
|
|
80
|
+
${at} #attr a { color: rgba(255,255,255,0.92); text-decoration: none; }`;
|
|
81
|
+
}
|
|
82
|
+
function scaleBarCss(at, scale) {
|
|
83
|
+
return `
|
|
73
84
|
${at} #scalebar {
|
|
74
85
|
position: absolute; left: ${Math.round(10 * scale)}px; bottom: ${Math.round(8 * scale)}px;
|
|
75
86
|
z-index: 1000; pointer-events: none;
|
|
@@ -85,6 +96,14 @@ export function sceneCss(src, theme, width, height, scale, scope) {
|
|
|
85
96
|
box-shadow: 0 1px 2px rgba(0,0,0,0.6);
|
|
86
97
|
}`;
|
|
87
98
|
}
|
|
99
|
+
export function sceneCss(src, theme, width, height, scale, scope) {
|
|
100
|
+
const at = `.${scope}`;
|
|
101
|
+
return (mapCss(at, src, theme, width, height) +
|
|
102
|
+
droneCss(at, theme, scale) +
|
|
103
|
+
chipCss(at, theme, scale) +
|
|
104
|
+
attrCss(at, scale) +
|
|
105
|
+
scaleBarCss(at, scale));
|
|
106
|
+
}
|
|
88
107
|
export function hudMarkup(hud) {
|
|
89
108
|
const chips = [];
|
|
90
109
|
if (hud.alt) {
|
|
@@ -95,14 +114,17 @@ export function hudMarkup(hud) {
|
|
|
95
114
|
}
|
|
96
115
|
return chips.map((chip) => ` ${chip}`).join('\n');
|
|
97
116
|
}
|
|
117
|
+
/** A null hud keeps the chips out of the map frame: the caller mounts them in
|
|
118
|
+
a strip outside the map image instead. */
|
|
98
119
|
export function mapMarkup(hud, attribution) {
|
|
120
|
+
const hudBlock = hud === null ? '' : `<div id="hud">
|
|
121
|
+
${hudMarkup(hud)}
|
|
122
|
+
</div>
|
|
123
|
+
`;
|
|
99
124
|
return `<div id="map-frame">
|
|
100
125
|
<div id="map"></div>
|
|
101
126
|
<div id="vignette"></div>
|
|
102
|
-
<div id="
|
|
103
|
-
${hudMarkup(hud)}
|
|
104
|
-
</div>
|
|
105
|
-
<div id="attr">${attribution}</div>
|
|
127
|
+
${hudBlock}<div id="attr">${attribution}</div>
|
|
106
128
|
<div id="scalebar"><span id="scaletext"></span><div id="scaleline"></div></div>
|
|
107
129
|
</div>`;
|
|
108
130
|
}
|