Skip to content

best way to save what you love

web/libav/wrapper: add support for encode variant

jj07443942fb74
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4aef65ae..da1ccaf2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -103,6 +103,9 @@ importers:
'@fontsource/redaction-10':
specifier: ^5.0.2
version: 5.0.2
+ '@imput/libav.js-encode-cli':
+ specifier: 6.5.7
+ version: 6.5.7
'@imput/libav.js-remux-cli':
specifier: ^6.5.7
version: 6.5.7
@@ -557,6 +560,9 @@ packages:
resolution: {integrity: sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==}
engines: {node: '>=18.18'}
+ '@imput/[email protected]':
+ resolution: {integrity: sha512-DbMBSibot7I8fASVmNVTIp0/WQrHUUV2jOCkjWBazvJQKr2hG288uFmvxUu+F2d3AFafRGA9xYtjsx8M+RULwQ==}
+
resolution: {integrity: sha512-41ld+R5aEwllKdbiszOoCf+K614/8bnuheTZnqjgZESwDtX07xu9O8GO0m/Cpsm7O2CyqPZa1qzDx6BZVO15DQ==}
@@ -2417,6 +2423,8 @@ snapshots:
'@humanwhocodes/[email protected]': {}
+ '@imput/[email protected]': {}
+
'@imput/[email protected]': {}
diff --git a/web/package.json b/web/package.json
index eb6a6c1f..49683f02 100644
--- a/web/package.json
+++ b/web/package.json
@@ -28,6 +28,7 @@
"@fontsource-variable/noto-sans-mono": "^5.0.20",
"@fontsource/ibm-plex-mono": "^5.0.13",
"@fontsource/redaction-10": "^5.0.2",
+ "@imput/libav.js-encode-cli": "6.5.7",
"@imput/libav.js-remux-cli": "^6.5.7",
"@imput/version-info": "workspace:^",
"@sveltejs/adapter-static": "^3.0.6",
diff --git a/web/src/lib/libav.ts b/web/src/lib/libav.ts
index 37e61276..7a58c321 100644
--- a/web/src/lib/libav.ts
+++ b/web/src/lib/libav.ts
@@ -1,5 +1,6 @@
import { OPFSStorage } from "$lib/storage";
import LibAV, { type LibAV as LibAVInstance } from "@imput/libav.js-remux-cli";
+import EncodeLibAV from "@imput/libav.js-encode-cli";
import type { FfprobeData } from "fluent-ffmpeg";
import type { FFmpegProgressCallback, FFmpegProgressEvent, FFmpegProgressStatus, RenderParams } from "$lib/types/libav";
@@ -16,13 +17,22 @@ export default class LibAVWrapper {
}
init(options?: LibAV.LibAVOpts) {
- if (!options) options = {
- yesthreads: true,
+ const variant = options?.variant || 'remux';
+ let constructor: typeof LibAV.LibAV;
+
+ if (variant === 'remux') {
+ constructor = LibAV.LibAV;
+ } else if (variant === 'encode') {
+ constructor = EncodeLibAV.LibAV;
+ } else {
+ throw "invalid variant";
}
if (this.concurrency && !this.libav) {
- this.libav = LibAV.LibAV({
+ this.libav = constructor({
...options,
+ variant: undefined,
+ yesthreads: true,
base: '/_libav'
});
}