diff --git a/README.md b/README.md index 6df01b6..923c57f 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,8 @@ All are optional, JWT_SECRET is recommended to be set. | ALLOW_UNAUTHENTICATED | false | Allow unauthenticated users to use the service, only set this to true locally | | AUTO_DELETE_EVERY_N_HOURS | 24 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable | | WEBROOT | | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" | -| FFMPEG_ARGS | | Arguments to pass to ffmpeg, e.g. `-preset veryfast` | +| FFMPEG_ARGS | | Arguments to pass to the input file of ffmpeg, e.g. `-hwaccel vaapi` | +| FFMPEG_OUTPUT_ARGS | | Arguments to pass to the output of ffmpeg, e.g. `-preset veryfast` | | HIDE_HISTORY | false | Hide the history page | | LANGUAGE | en | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) | | UNAUTHENTICATED_USER_SHARING | false | Shares conversion history between all unauthenticated users | diff --git a/mise.toml b/mise.toml index 89978a8..aa28d4b 100644 --- a/mise.toml +++ b/mise.toml @@ -3,4 +3,4 @@ bun = "1.2.2" [env] JWT_SECRET = "JustForDevelopmentPurposesOnlyChangeMeInProduction!" -FFMPEG_ARGS = "-preset veryfast -threads 2" +FFMPEG_OUTPUT_ARGS = "-preset veryfast -threads 2" diff --git a/src/converters/ffmpeg.ts b/src/converters/ffmpeg.ts index fc9618b..8418e2d 100644 --- a/src/converters/ffmpeg.ts +++ b/src/converters/ffmpeg.ts @@ -730,11 +730,14 @@ export async function convert( // Parse FFMPEG_ARGS environment variable into array const ffmpegArgs = process.env.FFMPEG_ARGS ? process.env.FFMPEG_ARGS.split(/\s+/) : []; + const ffmpegOutputArgs = process.env.FFMPEG_OUTPUT_ARGS + ? process.env.FFMPEG_OUTPUT_ARGS.split(/\s+/) + : []; return new Promise((resolve, reject) => { execFile( "ffmpeg", - ["-i", filePath, ...ffmpegArgs, ...extraArgs, targetPath], + [...ffmpegArgs, "-i", filePath, ...ffmpegOutputArgs, ...extraArgs, targetPath], (error, stdout, stderr) => { if (error) { reject(`error: ${error}`); diff --git a/tests/converters/ffmpeg.test.ts b/tests/converters/ffmpeg.test.ts index e841459..6f0afc6 100644 --- a/tests/converters/ffmpeg.test.ts +++ b/tests/converters/ffmpeg.test.ts @@ -135,7 +135,7 @@ test("respects FFMPEG_ARGS", async () => { console.log = originalConsoleLog; - expect(calls[0]?.slice(2, 4)).toEqual(["-hide_banner", "-y"]); + expect(calls[0]?.slice(0, 2)).toEqual(["-hide_banner", "-y"]); expect(loggedMessage).toBe("stdout: Fake stdout"); });