kopia lustrzana https://github.com/mifi/lossless-cut
upgrade file-type
rodzic
47a52dce5d
commit
5d5b4decd4
|
@ -0,0 +1,15 @@
|
|||
diff --git a/package.json b/package.json
|
||||
index 08f1ca3b598aa9f6ffdd35988744df1cd5ffcff6..d671d7ef0422c4f00f7d78fb5dd96a90c10c285a 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -25,6 +25,10 @@
|
||||
"./core": {
|
||||
"types": "./core.d.ts",
|
||||
"import": "./core.js"
|
||||
+ },
|
||||
+ "./node": {
|
||||
+ "types": "./index.d.ts",
|
||||
+ "import": "./index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
|
@ -135,7 +135,7 @@
|
|||
"execa": "^8.0.1",
|
||||
"express": "^4.19.2",
|
||||
"express-async-handler": "^1.2.0",
|
||||
"file-type": "^19.4.1",
|
||||
"file-type": "patch:file-type@npm%3A19.4.1#~/.yarn/patches/file-type-npm-19.4.1-d18086444c.patch",
|
||||
"fs-extra": "^8.1.0",
|
||||
"i18next": "^23.12.2",
|
||||
"i18next-fs-backend": "^2.3.2",
|
||||
|
|
|
@ -44,6 +44,7 @@ export { downloadMediaUrl } from './ffmpeg.js';
|
|||
|
||||
|
||||
const electronUnhandled = import('electron-unhandled');
|
||||
export const fileTypePromise = import('file-type/node');
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||
(async () => {
|
||||
|
|
|
@ -12,10 +12,9 @@ import { FFprobeChapter, FFprobeFormat, FFprobeProbeResult, FFprobeStream } from
|
|||
import { parseSrt, parseSrtToSegments } from './edlFormats';
|
||||
import { CopyfileStreams, LiteFFprobeStream } from './types';
|
||||
|
||||
const FileType = window.require('file-type');
|
||||
const { pathExists } = window.require('fs-extra');
|
||||
|
||||
const { ffmpeg } = window.require('@electron/remote').require('./index.js');
|
||||
const { ffmpeg, fileTypePromise } = window.require('@electron/remote').require('./index.js');
|
||||
|
||||
const { renderWaveformPng, mapTimesToSegments, detectSceneChanges, captureFrames, captureFrame, getFfCommandLine, runFfmpegConcat, runFfmpegWithProgress, html5ify, getDuration, abortFfmpegs, runFfmpeg, runFfprobe, getFfmpegPath, setCustomFfPath } = ffmpeg;
|
||||
|
||||
|
@ -272,7 +271,7 @@ async function determineOutputFormat(ffprobeFormatsStr: string | undefined, file
|
|||
// We need to test mp3 first because ffprobe seems to report the wrong format sometimes https://github.com/mifi/lossless-cut/issues/2129
|
||||
if (firstFfprobeFormat === 'mp3') {
|
||||
// file-type detects it correctly
|
||||
const fileTypeResponse = await FileType.fromFile(filePath);
|
||||
const fileTypeResponse = await (await fileTypePromise).fileTypeFromFile(filePath);
|
||||
if (fileTypeResponse?.mime === 'audio/mpeg') {
|
||||
return 'mp2';
|
||||
}
|
||||
|
@ -291,7 +290,7 @@ async function determineOutputFormat(ffprobeFormatsStr: string | undefined, file
|
|||
return firstFfprobeFormat;
|
||||
}
|
||||
|
||||
const fileTypeResponse = await FileType.fromFile(filePath);
|
||||
const fileTypeResponse = await (await fileTypePromise).fileTypeFromFile(filePath);
|
||||
if (fileTypeResponse == null) {
|
||||
console.warn('file-type failed to detect format, defaulting to first FFprobe detected format', ffprobeFormats);
|
||||
return firstFfprobeFormat;
|
||||
|
|
|
@ -9,7 +9,6 @@ import type fsPromises from 'node:fs/promises';
|
|||
import type fsExtraRaw from 'fs-extra';
|
||||
import type mimeTypes from 'mime-types';
|
||||
import type i18nextFsBackend from 'i18next-fs-backend';
|
||||
import type fileType from 'file-type';
|
||||
import type cueParser from 'cue-parser';
|
||||
|
||||
import '@fontsource/open-sans/300.css';
|
||||
|
@ -58,7 +57,6 @@ declare global {
|
|||
T extends 'fs-extra' ? FsExtra :
|
||||
T extends 'mime-types' ? typeof mimeTypes :
|
||||
T extends 'i18next-fs-backend' ? typeof i18nextFsBackend :
|
||||
T extends 'file-type' ? typeof fileType :
|
||||
T extends 'cue-parser' ? typeof cueParser :
|
||||
never
|
||||
);
|
||||
|
|
16
yarn.lock
16
yarn.lock
|
@ -5579,7 +5579,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"file-type@npm:^19.4.1":
|
||||
"file-type@npm:19.4.1":
|
||||
version: 19.4.1
|
||||
resolution: "file-type@npm:19.4.1"
|
||||
dependencies:
|
||||
|
@ -5591,6 +5591,18 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"file-type@patch:file-type@npm%3A19.4.1#~/.yarn/patches/file-type-npm-19.4.1-d18086444c.patch":
|
||||
version: 19.4.1
|
||||
resolution: "file-type@patch:file-type@npm%3A19.4.1#~/.yarn/patches/file-type-npm-19.4.1-d18086444c.patch::version=19.4.1&hash=31e3c3"
|
||||
dependencies:
|
||||
get-stream: "npm:^9.0.1"
|
||||
strtok3: "npm:^8.1.0"
|
||||
token-types: "npm:^6.0.0"
|
||||
uint8array-extras: "npm:^1.3.0"
|
||||
checksum: 10/9bfbcc1d15db351f77a3ace39baa397c19f79a755e3dd66c5d37a924ef7e424aa45583f9c88c262c3dabe6ae17c69b3451cb906abd396de7436497d3a9f99113
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"filelist@npm:^1.0.1":
|
||||
version: 1.0.4
|
||||
resolution: "filelist@npm:1.0.4"
|
||||
|
@ -7550,7 +7562,7 @@ __metadata:
|
|||
express: "npm:^4.19.2"
|
||||
express-async-handler: "npm:^1.2.0"
|
||||
fast-xml-parser: "npm:^4.4.1"
|
||||
file-type: "npm:^19.4.1"
|
||||
file-type: "patch:file-type@npm%3A19.4.1#~/.yarn/patches/file-type-npm-19.4.1-d18086444c.patch"
|
||||
framer-motion: "npm:^9.0.3"
|
||||
fs-extra: "npm:^8.1.0"
|
||||
i18next: "npm:^23.12.2"
|
||||
|
|
Ładowanie…
Reference in New Issue