Repository navigation
fix(cli): cloud render --json reports re-encode progress and times out a stalled cache check #7755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
miguel-heygen
wants to merge
1
commit into
main
Choose a base branch
from
fix/cloud-offload-progress
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+290
−29
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { execFileSync } from "node:child_process"; | ||
| import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { afterAll, describe, expect, it } from "vitest"; | ||
| import { findFfBinary } from "@hyperframes/parsers/ff-binaries"; | ||
| import { buildPublishFileMap } from "../utils/publishProject.js"; | ||
| import { OFFLOAD_MIN_BYTES, offloadHeavyMedia, type ReencodeProgress } from "./offload.js"; | ||
|
|
||
| const ffmpeg = findFfBinary("ffmpeg"); | ||
| const ffprobe = findFfBinary("ffprobe"); | ||
| const dir = mkdtempSync(join(tmpdir(), "hf-offload-progress-")); | ||
| afterAll(() => rmSync(dir, { recursive: true, force: true })); | ||
|
|
||
| /** Two seconds of video with sound, past the offload cutoff, under a name the asset API refuses. */ | ||
| function clipNeedingReencode(project: string): void { | ||
| const made = join(dir, "made.mov"); | ||
| execFileSync(ffmpeg!, [ | ||
| ...["-v", "error", "-y", "-f", "lavfi", "-i", "testsrc2=s=160x90:d=2"], | ||
| ...["-f", "lavfi", "-i", "sine=f=440:d=2"], | ||
| ...["-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", "-shortest", made], | ||
| ]); | ||
| const free = Buffer.alloc(OFFLOAD_MIN_BYTES); | ||
| free.writeUInt32BE(free.length); | ||
| free.write("free", 4); | ||
| writeFileSync(join(project, "take.mkv"), Buffer.concat([readFileSync(made), free])); | ||
| } | ||
|
|
||
| describe.skipIf(!ffmpeg || !ffprobe)("a re-encode before upload", () => { | ||
| it("reports the output seconds it has made, against the clip's length", async () => { | ||
| const project = mkdtempSync(join(dir, "project-")); | ||
| writeFileSync( | ||
| join(project, "index.html"), | ||
| `<html><body><video src="take.mkv"></video></body></html>`, | ||
| ); | ||
| clipNeedingReencode(project); | ||
| const heard: ReencodeProgress[] = []; | ||
|
|
||
| const [item] = await offloadHeavyMedia(project, buildPublishFileMap(project), { | ||
| apiBaseUrl: "https://api.example", | ||
| cachePath: join(project, "cache.json"), | ||
| upload: async () => ({ asset_id: "a", url: "https://assets.example/a.mp4" }), | ||
| onReencodeProgress: (event) => heard.push(event), | ||
| }); | ||
|
|
||
| expect(item).toMatchObject({ action: "reencode" }); | ||
| expect(heard.length).toBeGreaterThan(0); | ||
| const lastHeard = heard.at(-1)!; | ||
| expect(lastHeard.path).toBe("take.mkv"); | ||
| expect(lastHeard.doneSeconds).toBeGreaterThan(1.5); | ||
| expect(lastHeard.totalSeconds).toBeCloseTo(2, 0); | ||
| }); | ||
| }); |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
uploadPlannedalways passes a callback here, soonProgressis never undefined. Every re-encode of an untrimmed clip therefore runs an extra ffprobe, even without--json. To skip it when nobody is listening, pass the callback only whenctx.opts.onReencodeProgressis set.