Inline
This commit is contained in:
parent
5992efd58a
commit
8d6787b823
5 changed files with 39 additions and 41 deletions
|
@ -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";
|
||||
|
|
|
@ -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();
|
|
@ -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();
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Add table
Reference in a new issue