Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Web API (`/api/v1`) - This allows you to make your own apps, pages and overlays on the same JRTI feeds as the default proposed interface, with an optional control key for other devices if need be. Pages from other websites can no longer change anything, as a security measure. See the API page of the docs for more information
- Your own pages and styles (`PluginData/Apps/`, `PluginData/Web/`) - you can now make your own pages and styles, kept across updates
- Save recordings to this device (Settings, Finished recordings) - the web UI downloads each recording when it stops, so recordings land on the computer watching the feeds as well as the KSP one. On by default on every device except the KSP computer

## v3.3.0 - 2026-11-11

Expand Down
7 changes: 7 additions & 0 deletions GameData/JustReadTheInstructions/Web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ <h2 id="settings-title">Recorder settings</h2>
</p>
</div>

<div class="field">
<label for="settings-save">Finished recordings</label>
<select id="settings-save" class="input"></select>
<p class="hint">Each recording is still made in the game. Once it stops, this page downloads it here, so keep it open. Only recordings that finish while it is open are downloaded. On by default on every device except the KSP computer.</p>
<p class="hint hint-warning" id="settings-save-warning" hidden>On a phone or tablet, each recording can be several GB and is downloaded over your Wi-Fi or mobile data.</p>
</div>

<p class="hint hint-warning" id="settings-unavailable" hidden>
The game cannot record right now. JRTI's settings window in KSP (Ctrl+Alt+F8) says why.
</p>
Expand Down
2 changes: 2 additions & 0 deletions GameData/JustReadTheInstructions/Web/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fetchCameras } from './api.js';
import { CameraCard } from './camera-card.js';
import { mountSettingsUI } from './settings-ui.js';
import { mountRecordingsUI } from './recordings-ui.js';
import { syncRecordingsAutoSave } from './recordings-autosave.js';
import { enableDragOrder } from './drag-order.js';
import { RecordingGroups } from './recording-groups.js';
import { setInGameRecordingAvailable } from './recorder-settings.js';
Expand Down Expand Up @@ -185,6 +186,7 @@ function trackStatusLineHeight() {
async function main() {
mountSettingsUI();
mountRecordingsUI();
syncRecordingsAutoSave();
groups.mount(document.getElementById('groups-bar'));
trackStatusLineHeight();
await applySession();
Expand Down
14 changes: 13 additions & 1 deletion GameData/JustReadTheInstructions/Web/js/recorder-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import { VIDEO_CODECS } from './config.js';

const STORAGE_KEY = 'jrti.recorder.settings.v1';

const HOST_NAMES = ['localhost', '127.0.0.1', '[::1]'];

export const IS_HANDHELD = window.matchMedia('(pointer: coarse)').matches;

const DEFAULTS = Object.freeze({
codec: VIDEO_CODECS.H264,
saveToDevice: !HOST_NAMES.includes(location.hostname),
});

function isValidCodec(value) {
Expand All @@ -15,7 +20,10 @@ function load() {
const raw = localStorage.getItem(STORAGE_KEY);
if (!raw) return { ...DEFAULTS };
const parsed = JSON.parse(raw);
return { codec: isValidCodec(parsed.codec) ? parsed.codec : DEFAULTS.codec };
return {
codec: isValidCodec(parsed.codec) ? parsed.codec : DEFAULTS.codec,
saveToDevice: typeof parsed.saveToDevice === 'boolean' ? parsed.saveToDevice : DEFAULTS.saveToDevice,
};
} catch {
return { ...DEFAULTS };
}
Expand Down Expand Up @@ -50,6 +58,10 @@ export function selectedGameCodec() {
return gameCodecs.includes(cached.codec) ? cached.codec : DEFAULTS.codec;
}

export function savesRecordingsToDevice() {
return cached.saveToDevice;
}

export function isInGameRecordingAvailable() {
return inGameRecordingAvailable;
}
63 changes: 63 additions & 0 deletions GameData/JustReadTheInstructions/Web/js/recordings-autosave.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { API, RECORDINGS_REFRESH_MS } from './config.js';
import { fetchRecordings } from './api.js';
import { IS_HANDHELD, savesRecordingsToDevice, updateSettings } from './recorder-settings.js';
import { h } from './dom.js';
import { toast } from './ui.js';

const SAVED_KEY = 'jrti.recordings.saved.v1';
const SAVED_LIMIT = 100;

let timer = null;
let seen = null;

function claim(file) {
try {
const saved = JSON.parse(localStorage.getItem(SAVED_KEY)) ?? [];
if (saved.includes(file)) return false;
localStorage.setItem(SAVED_KEY, JSON.stringify([...saved, file].slice(-SAVED_LIMIT)));
} catch {
}
return true;
}

function download(file) {
const link = h('a', { href: API.recording(file, true), download: file, hidden: true });
document.body.append(link);
link.click();
link.remove();
if (IS_HANDHELD) toast(`Saving ${file} to this phone`, { label: 'Turn off', onAction: turnOff });
else toast(`Saving ${file} to this device`);
}

function turnOff() {
updateSettings({ saveToDevice: false });
syncRecordingsAutoSave();
toast('Recordings stay on the KSP computer. Turn this back on in Settings');
}

async function poll() {
let recordings;
try {
recordings = await fetchRecordings();
} catch {
return;
}
const finished = recordings.filter((r) => !r.recording).map((r) => r.file);
if (!seen) {
seen = new Set(finished);
return;
}
for (const file of finished.filter((f) => !seen.has(f))) {
seen.add(file);
if (claim(file)) download(file);
}
}

export function syncRecordingsAutoSave() {
clearInterval(timer);
timer = null;
seen = null;
if (!savesRecordingsToDevice()) return;
poll();
timer = setInterval(poll, RECORDINGS_REFRESH_MS);
}
17 changes: 16 additions & 1 deletion GameData/JustReadTheInstructions/Web/js/settings-ui.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { VIDEO_CODECS } from './config.js';
import { updateSettings, isInGameRecordingAvailable, getGameCodecs, selectedGameCodec } from './recorder-settings.js';
import { IS_HANDHELD, updateSettings, isInGameRecordingAvailable, getGameCodecs, selectedGameCodec, savesRecordingsToDevice } from './recorder-settings.js';
import { syncRecordingsAutoSave } from './recordings-autosave.js';
import { Sheet } from './ui.js';

const CODEC_LABELS = {
[VIDEO_CODECS.H264]: 'H.264 (default, plays everywhere)',
[VIDEO_CODECS.AV1]: 'AV1 (advanced, limited support)',
};

const SAVE_LABELS = {
keep: 'Keep on the KSP computer only',
device: 'Also save them to this device',
};

const CODEC_WARNING =
'Only change the codec if you know your video tools support it.\n\n' +
'H.264 opens in every editor, player, phone and OBS setup. AV1 keeps more detail at the same file size, ' +
Expand All @@ -29,6 +35,8 @@ function availableCodecLabels() {
function render(controls) {
const codec = selectedGameCodec();
renderOptions(controls.codec, availableCodecLabels(), codec);
renderOptions(controls.save, SAVE_LABELS, savesRecordingsToDevice() ? 'device' : 'keep');
document.getElementById('settings-save-warning').hidden = !(IS_HANDHELD && savesRecordingsToDevice());
document.getElementById('settings-codec-row').hidden = !isInGameRecordingAvailable();
document.getElementById('settings-unavailable').hidden = isInGameRecordingAvailable();
document.getElementById('settings-codec-warning').hidden = codec === VIDEO_CODECS.H264;
Expand All @@ -39,6 +47,7 @@ export function mountSettingsUI() {
const sheetEl = document.getElementById('settings-sheet');
const controls = {
codec: document.getElementById('settings-codec'),
save: document.getElementById('settings-save'),
};

if (!openBtn || !sheetEl || Object.values(controls).some((el) => !el)) return;
Expand All @@ -57,4 +66,10 @@ export function mountSettingsUI() {
updateSettings({ codec });
render(controls);
});

controls.save.addEventListener('change', () => {
updateSettings({ saveToDevice: controls.save.value === 'device' });
syncRecordingsAutoSave();
render(controls);
});
}
16 changes: 16 additions & 0 deletions docs/recording.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ Example: `Booster_Cam__cam10__2026-09-25_210455.mp4` is the camera named "Booste

The **Recordings** button at the top of the page lists every recording, newest first. **Play** opens one in a new tab and **Download** saves a copy to the device you are using, so you can open the web UI from another machine and copy a recording to it.

## Saving recordings on another computer

When you open the web UI on another computer, for example the one you stream or edit on, each recording is downloaded to that computer's Downloads folder when it stops. The recording stays on the KSP computer too.

This is on by default on every device except the KSP computer itself (the web UI opened as `localhost`). To turn it off on a device, open **Settings** there and set **Finished recordings** to **Keep on the KSP computer only**. The choice is remembered per browser.

* Keep the page open: only recordings that finish while it is open are downloaded.
* The first time, the browser may ask to allow the page to download several files. Allow it.
* With several tabs open in the same browser, only one of them downloads each recording.

!!! warning "On a phone or tablet"
This is on there too, and each recording can be several GB, downloaded over your Wi-Fi or mobile data. Each download shows a message with **Turn off**, and **Settings** warns about it while it is on.

!!! note
Recording on another computer does not make the game faster. To record or stream a camera, KSP has to draw it, and drawing it is what costs performance. Encoding the video is a small part of it. Fewer cameras, a lower resolution or a lower Max FPS help more.

## What a recording is

Every recording is an MP4 at the camera's render resolution, at a constant frame rate (Max FPS), with a keyframe every 2 seconds and a bitrate of 0.2 bits per pixel per frame (about 12 Mbps at 1080p 30 FPS).
Expand Down
Loading