Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Route

Manav Rathic84b6f6824df
diff --git a/web/packages/gallery/services/ffmpeg/index.ts b/web/packages/gallery/services/ffmpeg/index.ts
index 0d66151f3e..c5f3c8d81f 100644
--- a/web/packages/gallery/services/ffmpeg/index.ts
+++ b/web/packages/gallery/services/ffmpeg/index.ts
@@ -37,7 +37,7 @@ import { ffmpegExecWeb } from "./web";
*/
export const generateVideoThumbnailWeb = async (blob: Blob) =>
_generateVideoThumbnail((seekTime: number) =>
- ffmpegExecWeb(makeGenThumbnailCommand(seekTime, false), blob, "jpeg"),
+ ffmpegExecWeb(makeGenThumbnailCommand(seekTime), blob, "jpeg"),
);
const _generateVideoThumbnail = async (
@@ -73,16 +73,18 @@ export const generateVideoThumbnailNative = async (
) =>
_generateVideoThumbnail((seekTime: number) =>
electron.ffmpegExec(
- {
- default: makeGenThumbnailCommand(seekTime, false),
- hdr: makeGenThumbnailCommand(seekTime, true),
- },
+ makeGenThumbnailCommand(seekTime),
toDataOrPathOrZipEntry(desktopUploadItem),
"jpeg",
),
);
-const makeGenThumbnailCommand = (seekTime: number, forHDR: boolean) => [
+const makeGenThumbnailCommand = (seekTime: number) => ({
+ default: _makeGenThumbnailCommand(seekTime, false),
+ hdr: _makeGenThumbnailCommand(seekTime, true),
+});
+
+const _makeGenThumbnailCommand = (seekTime: number, forHDR: boolean) => [
ffmpegPathPlaceholder,
"-i",
inputPathPlaceholder,
diff --git a/web/packages/gallery/services/ffmpeg/web.ts b/web/packages/gallery/services/ffmpeg/web.ts
index f1b9a6912c..0a3628241a 100644
--- a/web/packages/gallery/services/ffmpeg/web.ts
+++ b/web/packages/gallery/services/ffmpeg/web.ts
@@ -1,6 +1,7 @@
import { FFmpeg } from "@ffmpeg/ffmpeg";
import { newID } from "ente-base/id";
import log from "ente-base/log";
+import type { FFmpegCommand } from "ente-base/types/ipc";
import { PromiseQueue } from "ente-utils/promise";
import {
ffmpegPathPlaceholder,
@@ -51,7 +52,7 @@ const createFFmpeg = async () => {
* {@link command} on {@link blob}.
*/
export const ffmpegExecWeb = async (
- command: string[],
+ command: FFmpegCommand,
blob: Blob,
outputFileExtension: string,
): Promise<Uint8Array> => {
@@ -68,7 +69,7 @@ export const ffmpegExecWeb = async (
const ffmpegExec = async (
ffmpeg: FFmpeg,
- command: string[],
+ command: FFmpegCommand,
outputFileExtension: string,
blob: Blob,
) => {
@@ -76,8 +77,6 @@ const ffmpegExec = async (
const outputSuffix = outputFileExtension ? "." + outputFileExtension : "";
const outputPath = newID("out_") + outputSuffix;
- const cmd = substitutePlaceholders(command, inputPath, outputPath);
-
const inputData = new Uint8Array(await blob.arrayBuffer());
// Exit status of the ffmpeg.exec invocation.
@@ -89,6 +88,16 @@ const ffmpegExec = async (
await ffmpeg.writeFile(inputPath, inputData);
+ const resolvedCommand = Array.isArray(command)
+ ? command
+ : command.default;
+
+ const cmd = substitutePlaceholders(
+ resolvedCommand,
+ inputPath,
+ outputPath,
+ );
+
status = await ffmpeg.exec(cmd);
if (status !== 0) {
log.info(