Created
October 4, 2024 08:44
-
-
Save JonnyBurger/96e1c1945e16ba1a54530d127f4060d5 to your computer and use it in GitHub Desktop.
Migrating the Remotion Recorder to the new captions format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We have migrated the captions format to the `Caption` type: | |
// https://remotion.dev/docs/captions/caption | |
// This will allow other captioning solutions as well. | |
// If you have already created captions, migrate them using: | |
// Run this with `bun migrate.ts` | |
import { toCaptions } from "@remotion/install-whisper-cpp"; | |
import { write } from "bun"; | |
import { readFileSync, readdirSync, statSync } from "node:fs"; | |
for (const item of readdirSync("public")) { | |
const isFolder = statSync(`public/${item}`).isDirectory(); | |
if (!isFolder) { | |
continue; | |
} | |
const subs = readdirSync(`public/${item}`).filter((f) => f.endsWith(".json")); | |
for (const sub of subs) { | |
const whisperCppOutput = JSON.parse( | |
readFileSync(`public/${item}/${sub}`, "utf-8"), | |
); | |
if (!whisperCppOutput.systeminfo) { | |
continue; | |
} | |
const { captions } = toCaptions({ whisperCppOutput }); | |
write(`public/${item}/${sub}`, JSON.stringify(captions, null, 2)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment