implement exiftool copy

exiftool-integration
Mikael Finstad 2022-02-13 22:36:24 +08:00
rodzic 158964fe08
commit 08c85d399b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 25AB36E3E81CBC26
4 zmienionych plików z 53 dodań i 2 usunięć

Wyświetl plik

@ -136,6 +136,9 @@
"asar": {
"smartUnpack": false
},
"asarUnpack": [
"node_modules/exiftool-vendored.*/**/*"
],
"appId": "no.mifi.losslesscut",
"artifactName": "${productName}-${os}.${ext}",
"afterSign": "electron-builder-notarize",
@ -417,5 +420,9 @@
"removable-media"
]
}
},
"optionalDependencies": {
"exiftool-vendored.exe": "^12.40.0",
"exiftool-vendored.pl": "^12.40.0"
}
}

25
src/exiftool.js 100644
Wyświetl plik

@ -0,0 +1,25 @@
const isDev = window.require('electron-is-dev');
const os = window.require('os');
const { join } = window.require('path');
const execa = window.require('execa');
function getPath() {
const platform = os.platform();
// todo test asar
// todo correct?
const subPath = platform === 'win32' ? 'exiftool-vendored.exe/bin/exiftool.exe' : 'exiftool-vendored.pl/bin/exiftool';
const path = `node_modules/${subPath}`;
return isDev ? path : join(process.resourcesPath, 'app.asar.unpacked', path);
}
// eslint-disable-next-line import/prefer-default-export
export async function exifToolCopyMeta(inPath, outPath) {
/* const existingTags = await exiftool.read(inPath);
console.log('existing tags', existingTags);
await await exiftool.write(outPath, existingTags); */
console.log('Copying exif data');
await execa(getPath(), ['-tagsFromFile', inPath, '-all:all', '-overwrite_original', outPath]);
console.log('Done copying exif data');
}

Wyświetl plik

@ -6,6 +6,7 @@ import pMap from 'p-map';
import { getOutPath, transferTimestamps, getOutFileExtension, getOutDir, isMac, deleteDispositionValue } from '../util';
import { isCuttingStart, isCuttingEnd, handleProgress, getFfCommandLine, getFfmpegPath, getDuration, runFfmpeg, createChaptersFromSegments } from '../ffmpeg';
import { exifToolCopyMeta } from '../exiftool';
const execa = window.require('execa');
const { join, resolve } = window.require('path');
@ -52,11 +53,17 @@ function getMatroskaFlags() {
const getChaptersInputArgs = (ffmetadataPath) => (ffmetadataPath ? ['-f', 'ffmetadata', '-i', ffmetadataPath] : []);
const enableExifToolCopyMeta = true; //todo
function useFfmpegOperations({ filePath, enableTransferTimestamps }) {
const optionalTransferTimestamps = useCallback(async (...args) => {
if (enableTransferTimestamps) await transferTimestamps(...args);
}, [enableTransferTimestamps]);
const optionalExifToolCopyMeta = useCallback(async (...args) => {
if (enableExifToolCopyMeta) await exifToolCopyMeta(...args);
}, []);
// const cut = useCallback(, [filePath, optionalTransferTimestamps]);
const cutMultiple = useCallback(async ({
@ -205,6 +212,7 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) {
const result = await process;
console.log(result.stdout);
await optionalExifToolCopyMeta(filePath, outPath);
await optionalTransferTimestamps(filePath, outPath, cutFrom);
}
@ -232,7 +240,7 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) {
}
return outFiles;
}, [filePath, optionalTransferTimestamps]);
}, [filePath, optionalTransferTimestamps, optionalExifToolCopyMeta]);
const mergeFiles = useCallback(async ({ paths, outDir, outPath, allStreams, outFormat, ffmpegExperimental, onProgress = () => {}, preserveMovData, movFastStart, chapters, preserveMetadataOnMerge }) => {
console.log('Merging files', { paths }, 'to', outPath);
@ -337,8 +345,9 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) {
if (chaptersPath) await fs.unlink(chaptersPath).catch((err) => console.error('Failed to delete', chaptersPath, err));
}
await optionalExifToolCopyMeta(paths[0], outPath);
await optionalTransferTimestamps(paths[0], outPath);
}, [optionalTransferTimestamps]);
}, [optionalTransferTimestamps, optionalExifToolCopyMeta]);
const autoMergeSegments = useCallback(async ({ customOutDir, isCustomFormatSelected, outFormat, segmentPaths, ffmpegExperimental, onProgress, preserveMovData, movFastStart, autoDeleteMergedSegments, chapterNames, preserveMetadataOnMerge }) => {
const ext = getOutFileExtension({ isCustomFormatSelected, outFormat, filePath });

Wyświetl plik

@ -5110,6 +5110,16 @@ execa@^5.0.0:
signal-exit "^3.0.3"
strip-final-newline "^2.0.0"
exiftool-vendored.exe@^12.40.0:
version "12.40.0"
resolved "https://registry.yarnpkg.com/exiftool-vendored.exe/-/exiftool-vendored.exe-12.40.0.tgz#0285fb4fc3b4495aa4c41f3784eb69b7d001a1c6"
integrity sha512-Ng7CGioXkX3msJzI8HxM5ZbtoUiw/4JFJSxe9d/kOqOo3nMqStB8sqtwjmilsHAyuW2JIGkUtZ+IxPkuzRrmyA==
exiftool-vendored.pl@^12.40.0:
version "12.40.0"
resolved "https://registry.yarnpkg.com/exiftool-vendored.pl/-/exiftool-vendored.pl-12.40.0.tgz#484b45114193167d67178f9c59af104fe8d9f177"
integrity sha512-yNoDhG6g8ifzgm0PPqgWTiI5vdbuTGyTgIlpy+hxeuf7M2b0x6tGtYNakjIO9Q08VDNxXIr1lEZJR2EMZ5JDTQ==
exit@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"