40 lines
893 B
TypeScript
40 lines
893 B
TypeScript
import { execa } from "execa";
|
|
import ffmpegPath from "ffmpeg-static";
|
|
import path from "node:path";
|
|
|
|
export async function encodeFrames({
|
|
inputPattern,
|
|
output,
|
|
fps = 30,
|
|
}: {
|
|
inputPattern: string;
|
|
output: string;
|
|
fps?: number;
|
|
}) {
|
|
console.log("kleje filmik");
|
|
await execa(ffmpegPath!, [
|
|
"-y",
|
|
"-pattern_type", "glob",
|
|
"-framerate", fps.toString(),
|
|
"-i", inputPattern.toString(),
|
|
|
|
"-i", path.resolve("./music.mp3"),
|
|
|
|
"-vf",
|
|
"transpose=2,scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2",
|
|
// "-autorotate",
|
|
|
|
"-c:v", "libx264",
|
|
"-pix_fmt", "yuv420p",
|
|
|
|
"-c:a", "mp3",
|
|
|
|
"-shortest",
|
|
"-fps_mode", "cfr",
|
|
// "-preset", "medium",
|
|
// "-crf", "18",
|
|
output,
|
|
]);
|
|
console.log("filmik sklejony");
|
|
}
|