// app/api/transcode/route.ts
import ffmpegPath from "ffmpeg-static";
import { spawn } from "node:child_process";
// Adds around 80 MB of binary, pushing toward the 250 MB cap.
// And on the Edge runtime this file won't even deploy:
// there is no child_process to spawn a binary with.
export const runtime = "nodejs"; // Edge is off the table
export async function POST(req: Request) {
const { videoUrl } = await req.json();
return new Promise((resolve) => {
const proc = spawn(ffmpegPath!, [
"-i", videoUrl, "-c:v", "libx264", "-crf", "23", "/tmp/out.mp4",
// The function holds open for the whole transcode and can hit
// the 300s wall (800s on Pro with maxDuration) on long jobs.
proc.on("close", () => resolve(Response.json({ ok: true })));