diff --git a/package.json b/package.json index 920d33084..ef08b7597 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,9 @@ "@babel/core": "^7.20.7", "@electron/remote": "^2.0.8", "@entrylabs/modal": "^1.2.7", + "@ffmpeg-installer/ffmpeg": "^1.1.0", + "@ffprobe-installer/ffprobe": "^2.1.2", + "@types/fluent-ffmpeg": "^2.1.24", "async-csv": "^2.1.3", "axios": "^0.19.2", "cross-spawn": "^7.0.3", @@ -40,8 +43,8 @@ "entry-js": "git+https://github.com/entrylabs/entryjs.git#dist/offline_v2.1.12", "entry-tool": "git+https://github.com/entrylabs/entry-tool.git#dist/20231026", "excel4node": "^1.7.0", - "fs-extra": "^8.1.0", "fluent-ffmpeg": "^2.1.2", + "fs-extra": "^8.1.0", "image-size": "^0.8.3", "jquery": "^3.4.1", "literallycanvas-mobile": "git+https://github.com/entrylabs/literallycanvas#feature/mobile", @@ -50,7 +53,6 @@ "music-metadata": "^6.3.0", "node-abi": "^3.28.0", "node-xlsx": "^0.15.0", - "node-ffprobe": "^3.0.0", "puid": "^1.0.7", "rimraf": "^2.6.3", "sass": "^1.57.1", diff --git a/src/main/fileUtils.ts b/src/main/fileUtils.ts index 38730db23..9b8c2633d 100644 --- a/src/main/fileUtils.ts +++ b/src/main/fileUtils.ts @@ -5,8 +5,9 @@ import rimraf from 'rimraf'; import tar, { CreateOptions, FileOptions } from 'tar'; import { nativeImage, NativeImage } from 'electron'; import createLogger from './utils/functions/createLogger'; -import probe from 'node-ffprobe'; import ffmpeg from 'fluent-ffmpeg'; +import ffmpegInstaller from '@ffmpeg-installer/ffmpeg' +import ffprobeInstaller from '@ffprobe-installer/ffprobe' import get from 'lodash/get'; type tarCreateOption = FileOptions & CreateOptions; @@ -14,6 +15,16 @@ type readFileOption = { encoding?: string | null; flag?: string } | string | und type Dimension = { width: number; height: number }; const logger = createLogger('main/fileUtils.ts'); +const ffmpegPath = ffmpegInstaller.path.replace( + 'app.asar', + 'app.asar.unpacked' +); +const ffprobePath = ffprobeInstaller.path.replace( + 'app.asar', + 'app.asar.unpacked' +); +ffmpeg.setFfmpegPath(ffmpegPath); +ffmpeg.setFfprobePath(ffprobePath); export const ImageResizeSize: { [key: string]: Dimension } = { thumbnail: { width: 96, height: 96 }, @@ -288,7 +299,7 @@ export default class { static getSoundInfo = (filePath: string, isExtCheck = true): Promise => new Promise((resolve, reject) => { - probe(filePath).then((probeData: any, err: any) => { + ffmpeg.ffprobe(filePath, (err: any, probeData: any) => { if (err) { return reject(err); } diff --git a/types/index.d.ts b/types/index.d.ts index b8dbc7185..4c72c85ed 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -362,11 +362,3 @@ declare class Entry { static soundQueue: any; static stateManager: IEntry.StateManager; } - -declare module 'node-ffprobe' { - export default function probe(filePath: string): any; -} - -declare module 'fluent-ffmpeg' { - export default function ffmpeg(filePath: string): any; -} diff --git a/yarn.lock b/yarn.lock index f9bcfe6fd..a07029f53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -325,6 +325,114 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" +"@ffmpeg-installer/darwin-arm64@4.1.5": + version "4.1.5" + resolved "https://registry.yarnpkg.com/@ffmpeg-installer/darwin-arm64/-/darwin-arm64-4.1.5.tgz#b7b5c262dd96d1aea4807514e1cdcf6e11f82743" + integrity sha512-hYqTiP63mXz7wSQfuqfFwfLOfwwFChUedeCVKkBtl/cliaTM7/ePI9bVzfZ2c+dWu3TqCwLDRWNSJ5pqZl8otA== + +"@ffmpeg-installer/darwin-x64@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@ffmpeg-installer/darwin-x64/-/darwin-x64-4.1.0.tgz#48e1706c690e628148482bfb64acb67472089aaa" + integrity sha512-Z4EyG3cIFjdhlY8wI9aLUXuH8nVt7E9SlMVZtWvSPnm2sm37/yC2CwjUzyCQbJbySnef1tQwGG2Sx+uWhd9IAw== + +"@ffmpeg-installer/ffmpeg@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@ffmpeg-installer/ffmpeg/-/ffmpeg-1.1.0.tgz#87fdb9e7d180e8d78f7903f9441e36f978938a90" + integrity sha512-Uq4rmwkdGxIa9A6Bd/VqqYbT7zqh1GrT5/rFwCwKM70b42W5gIjWeVETq6SdcL0zXqDtY081Ws/iJWhr1+xvQg== + optionalDependencies: + "@ffmpeg-installer/darwin-arm64" "4.1.5" + "@ffmpeg-installer/darwin-x64" "4.1.0" + "@ffmpeg-installer/linux-arm" "4.1.3" + "@ffmpeg-installer/linux-arm64" "4.1.4" + "@ffmpeg-installer/linux-ia32" "4.1.0" + "@ffmpeg-installer/linux-x64" "4.1.0" + "@ffmpeg-installer/win32-ia32" "4.1.0" + "@ffmpeg-installer/win32-x64" "4.1.0" + +"@ffmpeg-installer/linux-arm64@4.1.4": + version "4.1.4" + resolved "https://registry.yarnpkg.com/@ffmpeg-installer/linux-arm64/-/linux-arm64-4.1.4.tgz#7219f3f901bb67f7926cb060b56b6974a6cad29f" + integrity sha512-dljEqAOD0oIM6O6DxBW9US/FkvqvQwgJ2lGHOwHDDwu/pX8+V0YsDL1xqHbj1DMX/+nP9rxw7G7gcUvGspSoKg== + +"@ffmpeg-installer/linux-arm@4.1.3": + version "4.1.3" + resolved "https://registry.yarnpkg.com/@ffmpeg-installer/linux-arm/-/linux-arm-4.1.3.tgz#c554f105ed5f10475ec25d7bec94926ce18db4c1" + integrity sha512-NDf5V6l8AfzZ8WzUGZ5mV8O/xMzRag2ETR6+TlGIsMHp81agx51cqpPItXPib/nAZYmo55Bl2L6/WOMI3A5YRg== + +"@ffmpeg-installer/linux-ia32@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@ffmpeg-installer/linux-ia32/-/linux-ia32-4.1.0.tgz#adad70b0d0d9d8d813983d6e683c5a338a75e442" + integrity sha512-0LWyFQnPf+Ij9GQGD034hS6A90URNu9HCtQ5cTqo5MxOEc7Rd8gLXrJvn++UmxhU0J5RyRE9KRYstdCVUjkNOQ== + +"@ffmpeg-installer/linux-x64@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@ffmpeg-installer/linux-x64/-/linux-x64-4.1.0.tgz#b4a5d89c4e12e6d9306dbcdc573df716ec1c4323" + integrity sha512-Y5BWhGLU/WpQjOArNIgXD3z5mxxdV8c41C+U15nsE5yF8tVcdCGet5zPs5Zy3Ta6bU7haGpIzryutqCGQA/W8A== + +"@ffmpeg-installer/win32-ia32@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@ffmpeg-installer/win32-ia32/-/win32-ia32-4.1.0.tgz#6eac4fb691b64c02e7a116c1e2d167f3e9b40638" + integrity sha512-FV2D7RlaZv/lrtdhaQ4oETwoFUsUjlUiasiZLDxhEUPdNDWcH1OU9K1xTvqz+OXLdsmYelUDuBS/zkMOTtlUAw== + +"@ffmpeg-installer/win32-x64@4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@ffmpeg-installer/win32-x64/-/win32-x64-4.1.0.tgz#17e8699b5798d4c60e36e2d6326a8ebe5e95a2c5" + integrity sha512-Drt5u2vzDnIONf4ZEkKtFlbvwj6rI3kxw1Ck9fpudmtgaZIHD4ucsWB2lCZBXRxJgXR+2IMSti+4rtM4C4rXgg== + +"@ffprobe-installer/darwin-arm64@5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@ffprobe-installer/darwin-arm64/-/darwin-arm64-5.0.1.tgz#a020a623955d55aa8daf45cb668c3044876b553b" + integrity sha512-vwNCNjokH8hfkbl6m95zICHwkSzhEvDC3GVBcUp5HX8+4wsX10SP3B+bGur7XUzTIZ4cQpgJmEIAx6TUwRepMg== + +"@ffprobe-installer/darwin-x64@5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@ffprobe-installer/darwin-x64/-/darwin-x64-5.1.0.tgz#f52316ac0bbe6f4ac70fdaea8db259ba4a055b00" + integrity sha512-J+YGscZMpQclFg31O4cfVRGmDpkVsQ2fZujoUdMAAYcP0NtqpC49Hs3SWJpBdsGB4VeqOt5TTm1vSZQzs1NkhA== + +"@ffprobe-installer/ffprobe@^2.1.2": + version "2.1.2" + resolved "https://registry.yarnpkg.com/@ffprobe-installer/ffprobe/-/ffprobe-2.1.2.tgz#ef9826b714cefe5e2debbe357afbb1ba738dfb32" + integrity sha512-ZNvwk4f2magF42Zji2Ese16SMj9BS7Fui4kRjg6gTYTxY3gWZNpg85n4MIfQyI9nimHg4x/gT6FVkp/bBDuBwg== + optionalDependencies: + "@ffprobe-installer/darwin-arm64" "5.0.1" + "@ffprobe-installer/darwin-x64" "5.1.0" + "@ffprobe-installer/linux-arm" "5.2.0" + "@ffprobe-installer/linux-arm64" "5.2.0" + "@ffprobe-installer/linux-ia32" "5.2.0" + "@ffprobe-installer/linux-x64" "5.2.0" + "@ffprobe-installer/win32-ia32" "5.1.0" + "@ffprobe-installer/win32-x64" "5.1.0" + +"@ffprobe-installer/linux-arm64@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@ffprobe-installer/linux-arm64/-/linux-arm64-5.2.0.tgz#b6cb3735792d9d012d1caba4de2a6f90af2a8966" + integrity sha512-X1VvWtlLs6ScP73biVLuHD5ohKJKsMTa0vafCESOen4mOoNeLAYbxOVxDWAdFz9cpZgRiloFj5QD6nDj8E28yQ== + +"@ffprobe-installer/linux-arm@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@ffprobe-installer/linux-arm/-/linux-arm-5.2.0.tgz#0120863c181303a1610b1e6956c6a5492d6c45a6" + integrity sha512-PF5HqEhCY7WTWHtLDYbA/+rLS+rhslWvyBlAG1Fk8VzVlnRdl93o6hy7DE2kJgxWQbFaR3ZktPQGEzfkrmQHvQ== + +"@ffprobe-installer/linux-ia32@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@ffprobe-installer/linux-ia32/-/linux-ia32-5.2.0.tgz#d42a892003811b5e1f2c958d330b841ef6ff3233" + integrity sha512-TFVK5sasXyXhbIG7LtPRDmtkrkOsInwKcL43iEvEw+D9vCS2rc//mn9/0Q+BR0UoJEiMK4+ApYr/3LLVUBPOCQ== + +"@ffprobe-installer/linux-x64@5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@ffprobe-installer/linux-x64/-/linux-x64-5.2.0.tgz#5dd8dbd51d130b5997bf49cb874e1f92e97f02e7" + integrity sha512-D3UeqTLYPNs7pBWPLUYGehPdRVqU8eACox4OZy3pZUZatxye2YKlvBwEfaLdL1v2Z4FOAlLUhms0kY8m8kqSRA== + +"@ffprobe-installer/win32-ia32@5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@ffprobe-installer/win32-ia32/-/win32-ia32-5.1.0.tgz#43b1462b9d89570fe3723c20b66bab684516751a" + integrity sha512-5O3vOoNRxmut0/Nu9vSazTdSHasrr+zPT2B3Hm7kjmO3QVFcIfVImS6ReQnZeSy8JPJOqXts5kX5x/3KOX54XQ== + +"@ffprobe-installer/win32-x64@5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@ffprobe-installer/win32-x64/-/win32-x64-5.1.0.tgz#87841123e8b903cc327f1e5b9aa69e5d2fbe6d7b" + integrity sha512-jMGYeAgkrdn4e2vvYt/qakgHRE3CPju4bn5TmdPfoAm1BlX1mY9cyMd8gf5vSzI8gH8Zq5WQAyAkmekX/8TSTg== + "@gar/promisify@^1.1.3": version "1.1.3" resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" @@ -630,6 +738,13 @@ resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== +"@types/fluent-ffmpeg@^2.1.24": + version "2.1.24" + resolved "https://registry.yarnpkg.com/@types/fluent-ffmpeg/-/fluent-ffmpeg-2.1.24.tgz#f53c57700bc4360ac638554545c8da2c465434c1" + integrity sha512-g5oQO8Jgi2kFS3tTub7wLvfLztr1s8tdXmRd8PiL/hLMLzTIAyMR2sANkTggM/rdEDAg3d63nYRRVepwBiCw5A== + dependencies: + "@types/node" "*" + "@types/fs-extra@^9.0.1", "@types/fs-extra@^9.0.11": version "9.0.13" resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45" @@ -6164,11 +6279,6 @@ node-environment-flags@1.0.6: object.getownpropertydescriptors "^2.0.3" semver "^5.7.0" -node-ffprobe@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/node-ffprobe/-/node-ffprobe-3.0.0.tgz#e6a9f6942fb2dc9c0897a68c9292a366b10bccd7" - integrity sha512-2LNTLStz2hw/urwo4xJ00TIOvthgepcl3tF4HB8BWnhJ4nhJ7S08YThapBHkGLYV+GUuY9pML/kX76+dqY2iUg== - node-gyp-build@^4.2.1: version "4.5.0" resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.5.0.tgz#7a64eefa0b21112f89f58379da128ac177f20e40"