mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
* feat(aws-lambda): arm64 video function image from the handler ZIP The image is the release handler ZIP with its x86 ffmpeg and Chrome swapped for the native ffmpeg tree and the sha256-pinned Sparticuz arm64 Chrome pack, so the x86 and arm64 functions run the same handler code. The image stage only copies, so any host builds it. CI builds it and runs ffmpeg, a real Chrome render and the Lambda runtime on an ARM runner. * fix(aws-lambda): launch Chrome in the image smoke the way Lambda does @sparticuz/chromium inflates its AL2023 libraries only when AWS_EXECUTION_ENV names a Node runtime; Lambda sets it, a bare docker run does not. The workflow also runs on @sparticuz/chromium bumps and handler ZIP layout changes, which re-stage the image. * fix(aws-lambda): smoke the arm64 image through its own Lambda runtime The smoke is now a handler invoked through the image's entrypoint, whose bootstrap sets AWS_EXECUTION_ENV the way Lambda does, so @sparticuz/chromium takes its Lambda branch with nothing set by hand. It returns the value it saw. * fix(aws-lambda): agree the move of the ffmpeg build workflow into the image workflow * fix(aws-lambda): build the Chrome pack URL from the pin and hand the checked pack to tar in memory
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
// A handler mounted into the video image and invoked through its own Lambda bootstrap, which sets
|
|
// AWS_EXECUTION_ENV as Lambda does: the bundled ffmpeg answers and arm64 Chrome renders, launched as
|
|
// src/chromium.ts launches it.
|
|
import { execFileSync } from "node:child_process";
|
|
import chromium from "@sparticuz/chromium";
|
|
import puppeteer from "puppeteer-core";
|
|
|
|
export const handler = async () => {
|
|
const ffmpeg = execFileSync("/var/task/bin/ffmpeg", ["-hide_banner", "-version"], {
|
|
encoding: "utf-8",
|
|
}).split("\n")[0];
|
|
const browser = await puppeteer.launch({
|
|
executablePath: await chromium.executablePath(),
|
|
args: chromium.args,
|
|
});
|
|
try {
|
|
const page = await browser.newPage();
|
|
await page.setContent("<div style='width:64px;height:64px;background:#0a0'></div>");
|
|
const shot = await page.screenshot({ clip: { x: 0, y: 0, width: 64, height: 64 } });
|
|
return {
|
|
executionEnv: process.env.AWS_EXECUTION_ENV,
|
|
arch: process.arch,
|
|
ffmpeg,
|
|
chrome: await browser.version(),
|
|
screenshotBytes: shot.length,
|
|
};
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
};
|