From 7d723fd27674ae18a7d812aa6903a735fe5e10c9 Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Wed, 18 Nov 2026 17:50:55 -0500 Subject: [PATCH] Revert "fix(engine): write every concat list through one writer that refuses control characters" This reverts commit 97d482340ad4e741383ec7cce712406288222236. --- packages/engine/src/index.ts | 2 +- packages/engine/src/services/chunkEncoder.ts | 11 +++-------- packages/parsers/src/ffBinaries.ts | 17 ----------------- .../src/services/distributed/assemble.ts | 5 +++-- .../src/helpers/proxyTranscoder.ts | 10 ++++------ 5 files changed, 11 insertions(+), 34 deletions(-) diff --git a/packages/engine/src/index.ts b/packages/engine/src/index.ts index 5996b80d4d..93c667f044 100644 --- a/packages/engine/src/index.ts +++ b/packages/engine/src/index.ts @@ -198,7 +198,7 @@ export { } from "./services/screenshotService.js"; // ── Encoding ─────────────────────────────────────────────────────────────────── -export { concatListInputArgs, concatListText } from "@hyperframes/parsers/ff-binaries"; +export { concatListInputArgs } from "@hyperframes/parsers/ff-binaries"; export { buildEncoderArgs, encodeFramesFromDir, diff --git a/packages/engine/src/services/chunkEncoder.ts b/packages/engine/src/services/chunkEncoder.ts index 6e00f22515..0a939ff4eb 100644 --- a/packages/engine/src/services/chunkEncoder.ts +++ b/packages/engine/src/services/chunkEncoder.ts @@ -50,7 +50,7 @@ import { appendVp9CpuUsedArg } from "./vp9Options.js"; import { appendSoftwareEncoderThreadsArg } from "./softwareEncoderThreads.js"; import { appendRenderProvenanceArgs } from "../utils/renderProvenance.js"; import { createStagingDir } from "@hyperframes/core/atomic-file"; -import { concatListInputArgs, concatListText } from "@hyperframes/parsers/ff-binaries"; +import { concatListInputArgs } from "@hyperframes/parsers/ff-binaries"; export type { EncoderOptions, EncodeResult, MuxResult } from "./chunkEncoder.types.js"; @@ -693,7 +693,7 @@ let concatListSeq = 0; function writeConcatList(dir: string, inputPaths: readonly string[]): string { concatListSeq += 1; const listPath = join(dir, `concat-list-${process.pid}-${concatListSeq}.txt`); - const body = concatListText(inputPaths.map((p) => resolve(p))); + const body = inputPaths.map((p) => `file '${resolve(p).replace(/'/g, "'\\''")}'`).join("\n"); writeFileSync(listPath, body, "utf-8"); return listPath; } @@ -721,12 +721,7 @@ export async function concatVideoFiles( // get their own chunk directory but can share an output directory. // The list is left on disk deliberately: it is removed with the work dir, // and `--debug` keeps both so a bad concat can be reproduced from its list. - let listPath: string; - try { - listPath = writeConcatList(dirname(firstInput), inputPaths); - } catch (error) { - return { success: false, error: (error as Error).message, externalInterruption: false }; - } + const listPath = writeConcatList(dirname(firstInput), inputPaths); const encodeTimeout = config?.ffmpegEncodeTimeout ?? DEFAULT_CONFIG.ffmpegEncodeTimeout; const result = await runFfmpeg(buildConcatArgs(listPath, outputPath), { signal, diff --git a/packages/parsers/src/ffBinaries.ts b/packages/parsers/src/ffBinaries.ts index 68f04ab606..9f2da0b89c 100644 --- a/packages/parsers/src/ffBinaries.ts +++ b/packages/parsers/src/ffBinaries.ts @@ -249,23 +249,6 @@ export function clearFfBinaryLookupCache(): void { skippedX86Binaries.clear(); } -const holdsControlCharacter = (text: string) => - [...text].some((char) => char < " " || char === "\u007f"); - -/** One `file` entry per path; a control character (a line break starts a list line) is refused. */ -export function concatListText(paths: readonly string[]): string { - return paths - .map((path) => { - if (holdsControlCharacter(path)) { - throw new Error( - `A file to join holds a control character in its path: ${JSON.stringify(path)}`, - ); - } - return `file '${path.replace(/'/g, "'\\''")}'\n`; - }) - .join(""); -} - /** * Concat input for a list HyperFrames wrote: entries open only as local mov, matroska or concat * files (an ffconcat entry is followed in safe mode), and `-xerror` fails at a refused entry. diff --git a/packages/producer/src/services/distributed/assemble.ts b/packages/producer/src/services/distributed/assemble.ts index 3e16e3dd36..4f700bc528 100644 --- a/packages/producer/src/services/distributed/assemble.ts +++ b/packages/producer/src/services/distributed/assemble.ts @@ -39,7 +39,6 @@ import { appendRateCapArgs, appendRenderProvenanceArgs, concatListInputArgs, - concatListText, describeFfmpegFailure, getEncoderPreset, MIXED_AUDIO_FILENAME, @@ -394,8 +393,10 @@ function concatDemuxerInput( workDir: string, fpsArg: string, ): string[] { + // ffmpeg's concat list escapes a single quote as `'\''`. const listPath = join(workDir, "concat-list.txt"); - writeFileSync(listPath, concatListText(chunkPaths), "utf-8"); + const body = chunkPaths.map((path) => `file '${path.replace(/'/g, "'\\''")}'`).join("\n"); + writeFileSync(listPath, `${body}\n`, "utf-8"); return ["-r", fpsArg, ...concatListInputArgs(listPath)]; } diff --git a/packages/studio-server/src/helpers/proxyTranscoder.ts b/packages/studio-server/src/helpers/proxyTranscoder.ts index bc48bca058..e6d03e4c25 100644 --- a/packages/studio-server/src/helpers/proxyTranscoder.ts +++ b/packages/studio-server/src/helpers/proxyTranscoder.ts @@ -7,7 +7,6 @@ import { hdrToSdrToneMapFilter, type PreviewProxyBox } from "@hyperframes/core"; import { previewToken } from "@hyperframes/core/preview-proof"; import { concatListInputArgs, - concatListText, findFfBinary, followFfmpegProgress, } from "@hyperframes/parsers/ff-binaries"; @@ -660,11 +659,10 @@ async function encodeInChunks( try { writeFileSync( listPath, - concatListText( - pieces.map((piece) => - JOIN_FROM_CACHE_FOLDER ? basename(piece) : piece.replace(/\\/g, "/"), - ), - ), + pieces + .map((piece) => (JOIN_FROM_CACHE_FOLDER ? basename(piece) : piece.replace(/\\/g, "/"))) + .map((piece) => `file '${piece.replace(/'/g, "'\\''")}'\n`) + .join(""), ); await concat(listPath, tempPath); } finally {