Manav Rathi 1 年之前
父节点
当前提交
71cf2c30d7
共有 1 个文件被更改,包括 3 次插入10 次删除
  1. 3 10
      web/apps/photos/src/services/wasm/ffmpeg.ts

+ 3 - 10
web/apps/photos/src/services/wasm/ffmpeg.ts

@@ -1,3 +1,4 @@
+import { nameAndExtension } from "@/next/file";
 import log from "@/next/log";
 import log from "@/next/log";
 import { withTimeout } from "@ente/shared/utils";
 import { withTimeout } from "@ente/shared/utils";
 import QueueProcessor from "@ente/shared/utils/queueProcessor";
 import QueueProcessor from "@ente/shared/utils/queueProcessor";
@@ -7,7 +8,7 @@ import {
     INPUT_PATH_PLACEHOLDER,
     INPUT_PATH_PLACEHOLDER,
     OUTPUT_PATH_PLACEHOLDER,
     OUTPUT_PATH_PLACEHOLDER,
 } from "constants/ffmpeg";
 } from "constants/ffmpeg";
-import { createFFmpeg, FFmpeg } from "ffmpeg-wasm";
+import { FFmpeg, createFFmpeg } from "ffmpeg-wasm";
 import { getUint8ArrayView } from "services/readerService";
 import { getUint8ArrayView } from "services/readerService";
 
 
 const FFMPEG_EXECUTION_WAIT_TIME = 30 * 1000;
 const FFMPEG_EXECUTION_WAIT_TIME = 30 * 1000;
@@ -65,7 +66,7 @@ export class WasmFFmpeg {
         let tempOutputFilePath: string;
         let tempOutputFilePath: string;
         try {
         try {
             await this.ready;
             await this.ready;
-            const extension = getFileExtension(inputFile.name);
+            const [, extension] = nameAndExtension(inputFile.name);
             const tempNameSuffix = extension ? `input.${extension}` : "input";
             const tempNameSuffix = extension ? `input.${extension}` : "input";
             tempInputFilePath = `${generateTempName(10, tempNameSuffix)}`;
             tempInputFilePath = `${generateTempName(10, tempNameSuffix)}`;
             this.ffmpeg.FS(
             this.ffmpeg.FS(
@@ -106,11 +107,3 @@ export class WasmFFmpeg {
         }
         }
     }
     }
 }
 }
-
-function getFileExtension(filename: string) {
-    const lastDotPosition = filename.lastIndexOf(".");
-    if (lastDotPosition === -1) return null;
-    else {
-        return filename.slice(lastDotPosition + 1);
-    }
-}