Skip to content

armgit / ente

Public Imported from GitHub
0

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

Inline

Manav Rathi8d6787b823c8
diff --git a/web/apps/photos/src/services/download/index.ts b/web/apps/photos/src/services/download/index.ts
index 81aae1bf50..bb7cf0bcf8 100644
--- a/web/apps/photos/src/services/download/index.ts
+++ b/web/apps/photos/src/services/download/index.ts
@@ -10,7 +10,7 @@ import { isPlaybackPossible } from "@ente/shared/media/video-playback";
import { Remote } from "comlink";
import { FILE_TYPE } from "constants/file";
import isElectron from "is-electron";
-import * as ffmpegService from "services/ffmpeg/ffmpegService";
+import * as ffmpegService from "services/ffmpeg";
import { EnteFile } from "types/file";
import { generateStreamFromArrayBuffer, getRenderableImage } from "utils/file";
import { PhotosDownloadClient } from "./clients/photos";
diff --git a/web/apps/photos/src/services/ffmpeg/ffmpegService.ts b/web/apps/photos/src/services/ffmpeg.ts
similarity index 75%
rename from web/apps/photos/src/services/ffmpeg/ffmpegService.ts
rename to web/apps/photos/src/services/ffmpeg.ts
index 0a6a66cb05..75b67d33aa 100644
--- a/web/apps/photos/src/services/ffmpeg/ffmpegService.ts
+++ b/web/apps/photos/src/services/ffmpeg.ts
@@ -5,8 +5,8 @@ import {
OUTPUT_PATH_PLACEHOLDER,
} from "constants/ffmpeg";
import { ElectronFile } from "types/upload";
+import ComlinkFFmpegWorker from "utils/comlink/ComlinkFFmpegWorker";
import { parseFFmpegExtractedMetadata } from "utils/ffmpeg";
-import ffmpegFactory from "./ffmpegFactory";
export async function generateVideoThumbnail(
file: File | ElectronFile,
@@ -98,3 +98,38 @@ export async function convertToMP4(file: File | ElectronFile) {
throw e;
}
}
+
+interface IFFmpeg {
+ run: (
+ cmd: string[],
+ inputFile: File | ElectronFile,
+ outputFilename: string,
+ dontTimeout?: boolean,
+ ) => Promise<File | ElectronFile>;
+}
+
+class FFmpegFactory {
+ private client: IFFmpeg;
+ async getFFmpegClient() {
+ if (!this.client) {
+ const electron = globalThis.electron;
+ if (electron) {
+ this.client = {
+ run(cmd, inputFile, outputFilename, dontTimeout) {
+ return electron.runFFmpegCmd(
+ cmd,
+ inputFile,
+ outputFilename,
+ dontTimeout,
+ );
+ },
+ };
+ } else {
+ this.client = await ComlinkFFmpegWorker.getInstance();
+ }
+ }
+ return this.client;
+ }
+}
+
+const ffmpegFactory = new FFmpegFactory();
diff --git a/web/apps/photos/src/services/ffmpeg/ffmpegFactory.ts b/web/apps/photos/src/services/ffmpeg/ffmpegFactory.ts
deleted file mode 100644
index 49aee9868e..0000000000
--- a/web/apps/photos/src/services/ffmpeg/ffmpegFactory.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { ElectronFile } from "types/upload";
-import ComlinkFFmpegWorker from "utils/comlink/ComlinkFFmpegWorker";
-
-export interface IFFmpeg {
- run: (
- cmd: string[],
- inputFile: File | ElectronFile,
- outputFilename: string,
- dontTimeout?: boolean,
- ) => Promise<File | ElectronFile>;
-}
-
-class FFmpegFactory {
- private client: IFFmpeg;
- async getFFmpegClient() {
- if (!this.client) {
- const electron = globalThis.electron;
- if (electron) {
- this.client = {
- run(cmd, inputFile, outputFilename, dontTimeout) {
- return electron.runFFmpegCmd(
- cmd,
- inputFile,
- outputFilename,
- dontTimeout,
- );
- },
- };
- } else {
- this.client = await ComlinkFFmpegWorker.getInstance();
- }
- }
- return this.client;
- }
-}
-
-export default new FFmpegFactory();
diff --git a/web/apps/photos/src/services/upload/metadataService.ts b/web/apps/photos/src/services/upload/metadataService.ts
index 13acf3d650..904a59d592 100644
--- a/web/apps/photos/src/services/upload/metadataService.ts
+++ b/web/apps/photos/src/services/upload/metadataService.ts
@@ -11,7 +11,7 @@ import {
import { Remote } from "comlink";
import { FILE_TYPE } from "constants/file";
import { FILE_READER_CHUNK_SIZE, NULL_LOCATION } from "constants/upload";
-import * as ffmpegService from "services/ffmpeg/ffmpegService";
+import * as ffmpegService from "services/ffmpeg";
import { getElectronFileStream, getFileStream } from "services/readerService";
import { getFileType } from "services/typeDetectionService";
import { FilePublicMagicMetadataProps } from "types/file";
diff --git a/web/apps/photos/src/services/upload/thumbnail.ts b/web/apps/photos/src/services/upload/thumbnail.ts
index c5e8be29cb..69848d6dc2 100644
--- a/web/apps/photos/src/services/upload/thumbnail.ts
+++ b/web/apps/photos/src/services/upload/thumbnail.ts
@@ -4,7 +4,7 @@ import { CustomErrorMessage, type Electron } from "@/next/types/ipc";
import { CustomError } from "@ente/shared/error";
import { FILE_TYPE } from "constants/file";
import { BLACK_THUMBNAIL_BASE64 } from "constants/upload";
-import * as FFmpegService from "services/ffmpeg/ffmpegService";
+import * as FFmpegService from "services/ffmpeg";
import HeicConversionService from "services/heicConversionService";
import { ElectronFile, FileTypeInfo } from "types/upload";
import { isFileHEIC } from "utils/file";