Files
hyperframes/packages/cli/src/commands/lambda/sites.ts
T
Miguel Ángel 3439433d67 perf(aws-lambda): a render reads a video's audio from a small file stored beside it (#6162)
* perf(aws-lambda): a render reads a video's audio from a small file stored beside it

A video's audio is interleaved with its pictures, so mixing it from the cloud read the whole video (2.5 GB for a 20-minute 4K film) at the Lambda's network speed. lambda sites create now stores each large video's audio packets as a separate object keyed by the video's hash; the audio task reads that when it exists.

* chore(producer): shorten the audio sidecar header comment

* fix(aws-lambda): no audio sidecar for a video whose audio starts late or that has several tracks

* test(producer): format the audio sidecar tests and end their ffprobe options with --
2026-10-23 23:12:52 +00:00

63 lines
2.3 KiB
TypeScript

/**
* `hyperframes lambda sites create <projectDir>` — upload a project's files
* to the deployed render bucket's shared content store. Used by adopters
* who want to pre-stage a project so multiple subsequent renders share the
* upload; files already in the bucket are skipped.
*/
import { resolve as resolvePath } from "node:path";
import { c } from "../../ui/colors.js";
import { DEFAULT_STACK_NAME, requireStack } from "./state.js";
// `@hyperframes/aws-lambda` is a workspace devDependency in `packages/cli`
// so the published CLI install stays small for users who don't deploy to
// Lambda. The lambda subverbs dynamic-import it on call. The dispatcher in
// `commands/lambda.ts` checks the import resolves before any subverb runs
// and prints a friendly install hint on `ERR_MODULE_NOT_FOUND`.
async function loadSDK(): Promise<typeof import("@hyperframes/aws-lambda/sdk")> {
return import("@hyperframes/aws-lambda/sdk");
}
export interface SitesCreateArgs {
projectDir: string;
stackName: string;
siteId?: string;
/** Print machine-readable JSON instead of the human-friendly summary. */
json: boolean;
}
export async function runSitesCreate(args: SitesCreateArgs): Promise<void> {
const stack = requireStack(args.stackName);
const projectDir = resolvePath(args.projectDir);
const { assertStackReadsSites, deploySite } = await loadSDK();
await assertStackReadsSites({ stateMachineArn: stack.stateMachineArn, region: stack.region });
const handle = await deploySite({
projectDir,
bucketName: stack.bucketName,
region: stack.region,
siteId: args.siteId,
onNotice: (message) => console.error(c.dim(message)),
});
if (args.json) {
console.log(JSON.stringify(handle, null, 2));
return;
}
console.log(
c.success(handle.uploaded ? "Site uploaded." : "Site already up to date (skipped upload)."),
);
console.log(` ${c.dim("Site ID:")} ${handle.siteId}`);
console.log(` ${c.dim("S3 URI:")} ${handle.projectS3Uri}`);
console.log(` ${c.dim("Bytes:")} ${handle.bytes}`);
console.log(` ${c.dim("Uploaded at:")} ${handle.uploadedAt}`);
console.log();
console.log(
c.dim(
`Render with: hyperframes lambda render ${args.projectDir} --site-id=${handle.siteId}` +
(args.stackName === DEFAULT_STACK_NAME ? "" : ` --stack-name=${args.stackName}`),
),
);
}