transcode: add -nostdin -safe 1

This commit is contained in:
Alex Gleason 2025-02-28 10:17:39 -06:00
parent 43ec58085a
commit aeaa60df45
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 9 additions and 1 deletions

View file

@ -1,4 +1,6 @@
export interface FFmpegFlags {
'safe'?: string;
'nostdin'?: string;
'c:v'?: string;
'preset'?: string;
'loglevel'?: string;
@ -15,7 +17,11 @@ export function ffmpeg(input: URL | ReadableStream<Uint8Array>, flags: FFmpegFla
for (const [key, value] of Object.entries(flags)) {
if (typeof value === 'string') {
if (value) {
args.push(`-${key}`, value);
} else {
args.push(`-${key}`);
}
}
}

View file

@ -2,6 +2,8 @@ import { ffmpeg } from './ffmpeg.ts';
export function transcodeVideo(input: ReadableStream<Uint8Array>): ReadableStream<Uint8Array> {
return ffmpeg(input, {
'safe': '1', // Safe mode
'nostdin': '', // Disable stdin
'c:v': 'libx264', // Convert to H.264
'preset': 'veryfast', // Encoding speed
'loglevel': 'fatal', // Suppress logs