1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 02:12:30 +01:00

Merge branch 'master' into ffmpeg-6

# Conflicts:
#	yarn.lock
This commit is contained in:
Mikael Finstad 2023-06-10 21:19:46 +01:00
commit dde7c225b5
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
7 changed files with 330 additions and 22 deletions

View File

@ -62,7 +62,7 @@
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"evergreen-ui": "^6.13.1",
"fast-xml-parser": "^4.0.3",
"fast-xml-parser": "^4.2.4",
"framer-motion": "^9.0.3",
"i18next-parser": "^7.6.0",
"icon-gen": "^3.0.0",
@ -91,7 +91,7 @@
"use-debounce": "^5.1.0",
"use-trace-update": "^1.3.0",
"uuid": "^8.3.2",
"vite": "^4.1.1",
"vite": "^4.1.5",
"vitest": "^0.28.5",
"wait-on": "^7.0.1"
},

View File

@ -1,7 +1,8 @@
import dataUriToBuffer from 'data-uri-to-buffer';
import pMap from 'p-map';
import { getSuffixedOutPath, getOutDir, transferTimestamps, getSuffixedFileName, getOutPath, escapeRegExp, getNumDigits } from '../util';
import { getSuffixedOutPath, getOutDir, transferTimestamps, getSuffixedFileName, getOutPath, escapeRegExp } from '../util';
import { getNumDigits } from '../segments';
import { captureFrame as ffmpegCaptureFrame, captureFrames as ffmpegCaptureFrames } from '../ffmpeg';

View File

@ -232,3 +232,10 @@ export function playOnlyCurrentSegment({ playbackMode, currentTime, playingSegme
return {};
}
export const getNumDigits = (value) => Math.floor(value > 0 ? Math.log10(value) : 0) + 1;
export function formatSegNum(segIndex, numSegments) {
const numDigits = getNumDigits(numSegments);
return `${segIndex + 1}`.padStart(numDigits, '0');
}

View File

@ -1,6 +1,6 @@
import { it, expect } from 'vitest';
import { test, it, expect } from 'vitest';
import { convertSegmentsToChapters, partitionIntoOverlappingRanges, getSegApparentStart, getSegApparentEnd } from './segments';
import { convertSegmentsToChapters, partitionIntoOverlappingRanges, getSegApparentStart, getSegApparentEnd, formatSegNum } from './segments';
it('converts segments to chapters with gaps', () => {
expect(convertSegmentsToChapters([
@ -109,3 +109,8 @@ it('detects overlapping segments, undefined end', () => {
[{ start: 1, end: undefined }, { start: 1.5, end: undefined }],
]);
});
test('formatSegNum', () => {
expect(formatSegNum(0, 9)).toBe('1');
expect(formatSegNum(0, 10)).toBe('01');
});

View File

@ -300,8 +300,6 @@ export function shuffleArray(arrayIn) {
return array;
}
export const getNumDigits = (value) => Math.floor(value > 0 ? Math.log10(value) : 0) + 1;
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
export function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string

View File

@ -1,9 +1,9 @@
import i18n from 'i18next';
import lodashTemplate from 'lodash/template';
import { isMac, isWindows, hasDuplicates, filenamify, getOutFileExtension, getNumDigits } from '../util';
import { isMac, isWindows, hasDuplicates, filenamify, getOutFileExtension } from '../util';
import isDev from '../isDev';
import { getSegmentTags } from '../segments';
import { getSegmentTags, formatSegNum } from '../segments';
export const segNumVariable = 'SEG_NUM';
@ -89,17 +89,12 @@ function interpolateSegmentFileName({ template, epochMs, inputFileNameWithoutExt
return compiled(data);
}
function formatSegNum(segIndex, segments) {
const numDigits = getNumDigits(segments);
return `${segIndex + 1}`.padStart(numDigits, '0');
}
export function generateOutSegFileNames({ segments, template, forceSafeOutputFileName, formatTimecode, isCustomFormatSelected, fileFormat, filePath, safeOutputFileName, maxLabelLength }) {
const epochMs = Date.now();
return segments.map((segment, i) => {
const { start, end, name = '' } = segment;
const segNum = formatSegNum(i, segments);
const segNum = formatSegNum(i, segments.length);
// Fields that did not come from the source file's name must be sanitized, because they may contain characters that are not supported by the target operating/file system
// however we disable this when the user has chosen to (safeOutputFileName === false)

316
yarn.lock
View File

@ -473,6 +473,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/android-arm64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/android-arm64@npm:0.17.19"
conditions: os=android & cpu=arm64
languageName: node
linkType: hard
"@esbuild/android-arm64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/android-arm64@npm:0.17.8"
@ -487,6 +494,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/android-arm@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/android-arm@npm:0.17.19"
conditions: os=android & cpu=arm
languageName: node
linkType: hard
"@esbuild/android-arm@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/android-arm@npm:0.17.8"
@ -501,6 +515,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/android-x64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/android-x64@npm:0.17.19"
conditions: os=android & cpu=x64
languageName: node
linkType: hard
"@esbuild/android-x64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/android-x64@npm:0.17.8"
@ -515,6 +536,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/darwin-arm64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/darwin-arm64@npm:0.17.19"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"@esbuild/darwin-arm64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/darwin-arm64@npm:0.17.8"
@ -529,6 +557,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/darwin-x64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/darwin-x64@npm:0.17.19"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"@esbuild/darwin-x64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/darwin-x64@npm:0.17.8"
@ -543,6 +578,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/freebsd-arm64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/freebsd-arm64@npm:0.17.19"
conditions: os=freebsd & cpu=arm64
languageName: node
linkType: hard
"@esbuild/freebsd-arm64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/freebsd-arm64@npm:0.17.8"
@ -557,6 +599,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/freebsd-x64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/freebsd-x64@npm:0.17.19"
conditions: os=freebsd & cpu=x64
languageName: node
linkType: hard
"@esbuild/freebsd-x64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/freebsd-x64@npm:0.17.8"
@ -571,6 +620,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/linux-arm64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/linux-arm64@npm:0.17.19"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard
"@esbuild/linux-arm64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/linux-arm64@npm:0.17.8"
@ -585,6 +641,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/linux-arm@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/linux-arm@npm:0.17.19"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard
"@esbuild/linux-arm@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/linux-arm@npm:0.17.8"
@ -599,6 +662,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/linux-ia32@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/linux-ia32@npm:0.17.19"
conditions: os=linux & cpu=ia32
languageName: node
linkType: hard
"@esbuild/linux-ia32@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/linux-ia32@npm:0.17.8"
@ -613,6 +683,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/linux-loong64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/linux-loong64@npm:0.17.19"
conditions: os=linux & cpu=loong64
languageName: node
linkType: hard
"@esbuild/linux-loong64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/linux-loong64@npm:0.17.8"
@ -627,6 +704,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/linux-mips64el@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/linux-mips64el@npm:0.17.19"
conditions: os=linux & cpu=mips64el
languageName: node
linkType: hard
"@esbuild/linux-mips64el@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/linux-mips64el@npm:0.17.8"
@ -641,6 +725,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/linux-ppc64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/linux-ppc64@npm:0.17.19"
conditions: os=linux & cpu=ppc64
languageName: node
linkType: hard
"@esbuild/linux-ppc64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/linux-ppc64@npm:0.17.8"
@ -655,6 +746,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/linux-riscv64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/linux-riscv64@npm:0.17.19"
conditions: os=linux & cpu=riscv64
languageName: node
linkType: hard
"@esbuild/linux-riscv64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/linux-riscv64@npm:0.17.8"
@ -669,6 +767,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/linux-s390x@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/linux-s390x@npm:0.17.19"
conditions: os=linux & cpu=s390x
languageName: node
linkType: hard
"@esbuild/linux-s390x@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/linux-s390x@npm:0.17.8"
@ -683,6 +788,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/linux-x64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/linux-x64@npm:0.17.19"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard
"@esbuild/linux-x64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/linux-x64@npm:0.17.8"
@ -697,6 +809,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/netbsd-x64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/netbsd-x64@npm:0.17.19"
conditions: os=netbsd & cpu=x64
languageName: node
linkType: hard
"@esbuild/netbsd-x64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/netbsd-x64@npm:0.17.8"
@ -711,6 +830,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/openbsd-x64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/openbsd-x64@npm:0.17.19"
conditions: os=openbsd & cpu=x64
languageName: node
linkType: hard
"@esbuild/openbsd-x64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/openbsd-x64@npm:0.17.8"
@ -725,6 +851,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/sunos-x64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/sunos-x64@npm:0.17.19"
conditions: os=sunos & cpu=x64
languageName: node
linkType: hard
"@esbuild/sunos-x64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/sunos-x64@npm:0.17.8"
@ -739,6 +872,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/win32-arm64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/win32-arm64@npm:0.17.19"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"@esbuild/win32-arm64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/win32-arm64@npm:0.17.8"
@ -753,6 +893,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/win32-ia32@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/win32-ia32@npm:0.17.19"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard
"@esbuild/win32-ia32@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/win32-ia32@npm:0.17.8"
@ -767,6 +914,13 @@ __metadata:
languageName: node
linkType: hard
"@esbuild/win32-x64@npm:0.17.19":
version: 0.17.19
resolution: "@esbuild/win32-x64@npm:0.17.19"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"@esbuild/win32-x64@npm:0.17.8":
version: 0.17.8
resolution: "@esbuild/win32-x64@npm:0.17.8"
@ -3769,6 +3923,83 @@ __metadata:
languageName: node
linkType: hard
"esbuild@npm:^0.17.5":
version: 0.17.19
resolution: "esbuild@npm:0.17.19"
dependencies:
"@esbuild/android-arm": 0.17.19
"@esbuild/android-arm64": 0.17.19
"@esbuild/android-x64": 0.17.19
"@esbuild/darwin-arm64": 0.17.19
"@esbuild/darwin-x64": 0.17.19
"@esbuild/freebsd-arm64": 0.17.19
"@esbuild/freebsd-x64": 0.17.19
"@esbuild/linux-arm": 0.17.19
"@esbuild/linux-arm64": 0.17.19
"@esbuild/linux-ia32": 0.17.19
"@esbuild/linux-loong64": 0.17.19
"@esbuild/linux-mips64el": 0.17.19
"@esbuild/linux-ppc64": 0.17.19
"@esbuild/linux-riscv64": 0.17.19
"@esbuild/linux-s390x": 0.17.19
"@esbuild/linux-x64": 0.17.19
"@esbuild/netbsd-x64": 0.17.19
"@esbuild/openbsd-x64": 0.17.19
"@esbuild/sunos-x64": 0.17.19
"@esbuild/win32-arm64": 0.17.19
"@esbuild/win32-ia32": 0.17.19
"@esbuild/win32-x64": 0.17.19
dependenciesMeta:
"@esbuild/android-arm":
optional: true
"@esbuild/android-arm64":
optional: true
"@esbuild/android-x64":
optional: true
"@esbuild/darwin-arm64":
optional: true
"@esbuild/darwin-x64":
optional: true
"@esbuild/freebsd-arm64":
optional: true
"@esbuild/freebsd-x64":
optional: true
"@esbuild/linux-arm":
optional: true
"@esbuild/linux-arm64":
optional: true
"@esbuild/linux-ia32":
optional: true
"@esbuild/linux-loong64":
optional: true
"@esbuild/linux-mips64el":
optional: true
"@esbuild/linux-ppc64":
optional: true
"@esbuild/linux-riscv64":
optional: true
"@esbuild/linux-s390x":
optional: true
"@esbuild/linux-x64":
optional: true
"@esbuild/netbsd-x64":
optional: true
"@esbuild/openbsd-x64":
optional: true
"@esbuild/sunos-x64":
optional: true
"@esbuild/win32-arm64":
optional: true
"@esbuild/win32-ia32":
optional: true
"@esbuild/win32-x64":
optional: true
bin:
esbuild: bin/esbuild
checksum: ac11b1a5a6008e4e37ccffbd6c2c054746fc58d0ed4a2f9ee643bd030cfcea9a33a235087bc777def8420f2eaafb3486e76adb7bdb7241a9143b43a69a10afd8
languageName: node
linkType: hard
"escalade@npm:^3.1.1":
version: 3.1.1
resolution: "escalade@npm:3.1.1"
@ -4199,14 +4430,14 @@ __metadata:
languageName: node
linkType: hard
"fast-xml-parser@npm:^4.0.3":
version: 4.0.3
resolution: "fast-xml-parser@npm:4.0.3"
"fast-xml-parser@npm:^4.2.4":
version: 4.2.4
resolution: "fast-xml-parser@npm:4.2.4"
dependencies:
strnum: ^1.0.5
bin:
fxparser: src/cli/cli.js
checksum: 100bb20bcc6aa1543fa277c81f64ad109abec80accacf0bf6bea61f5e847b5c8b734321da609dc10aea68ed68e380447ff3a27196942e137ef39e6e7eb6c053f
checksum: d3b4d0c0152c09f98def792769fca6bb3fa1d597f9745d9564451c239089bd86bdf573c9263b4944860028cb7edb81752d64399c1aff8b87c9225ecef96905f7
languageName: node
linkType: hard
@ -6211,7 +6442,7 @@ __metadata:
eslint-plugin-react-hooks: ^4.3.0
evergreen-ui: ^6.13.1
execa: ^7.1.1
fast-xml-parser: ^4.0.3
fast-xml-parser: ^4.2.4
file-type: 16
file-url: ^3.0.0
framer-motion: ^9.0.3
@ -6252,7 +6483,7 @@ __metadata:
use-debounce: ^5.1.0
use-trace-update: ^1.3.0
uuid: ^8.3.2
vite: ^4.1.1
vite: ^4.1.5
vitest: ^0.28.5
wait-on: ^7.0.1
winston: ^3.8.1
@ -6699,6 +6930,15 @@ __metadata:
languageName: node
linkType: hard
"nanoid@npm:^3.3.6":
version: 3.3.6
resolution: "nanoid@npm:3.3.6"
bin:
nanoid: bin/nanoid.cjs
checksum: 7d0eda657002738aa5206107bd0580aead6c95c460ef1bdd0b1a87a9c7ae6277ac2e9b945306aaa5b32c6dcb7feaf462d0f552e7f8b5718abfc6ead5c94a71b3
languageName: node
linkType: hard
"napi-build-utils@npm:^1.0.1":
version: 1.0.2
resolution: "napi-build-utils@npm:1.0.2"
@ -7400,6 +7640,17 @@ __metadata:
languageName: node
linkType: hard
"postcss@npm:^8.4.23":
version: 8.4.24
resolution: "postcss@npm:8.4.24"
dependencies:
nanoid: ^3.3.6
picocolors: ^1.0.0
source-map-js: ^1.0.2
checksum: 814e2126dacfea313588eda09cc99a9b4c26ec55c059188aa7a916d20d26d483483106dc5ff9e560731b59f45c5bb91b945dfadc670aed875cc90ddbbf4e787d
languageName: node
linkType: hard
"prebuild-install@npm:^7.0.0, prebuild-install@npm:^7.1.0":
version: 7.1.0
resolution: "prebuild-install@npm:7.1.0"
@ -8126,6 +8377,20 @@ __metadata:
languageName: node
linkType: hard
"rollup@npm:^3.21.0":
version: 3.23.1
resolution: "rollup@npm:3.23.1"
dependencies:
fsevents: ~2.3.2
dependenciesMeta:
fsevents:
optional: true
bin:
rollup: dist/bin/rollup
checksum: 4b3b3bbfd490b41ec5473d1141fe2beb0c86f600b56378fce97e0485192818256f8cbf4d43450b097ee7042e6629fb0187488807e2d15050860718f458c44685
languageName: node
linkType: hard
"rsvp@npm:^4.8.2":
version: 4.8.5
resolution: "rsvp@npm:4.8.5"
@ -9705,7 +9970,7 @@ __metadata:
languageName: node
linkType: hard
"vite@npm:^3.0.0 || ^4.0.0, vite@npm:^4.1.1":
"vite@npm:^3.0.0 || ^4.0.0":
version: 4.1.1
resolution: "vite@npm:4.1.1"
dependencies:
@ -9743,6 +10008,43 @@ __metadata:
languageName: node
linkType: hard
"vite@npm:^4.1.5":
version: 4.3.9
resolution: "vite@npm:4.3.9"
dependencies:
esbuild: ^0.17.5
fsevents: ~2.3.2
postcss: ^8.4.23
rollup: ^3.21.0
peerDependencies:
"@types/node": ">= 14"
less: "*"
sass: "*"
stylus: "*"
sugarss: "*"
terser: ^5.4.0
dependenciesMeta:
fsevents:
optional: true
peerDependenciesMeta:
"@types/node":
optional: true
less:
optional: true
sass:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
bin:
vite: bin/vite.js
checksum: 8c45a516278d1e0425fac00c0877336790f71484a851a318346a70e0d2aef9f3b9651deb2f9f002c791ceb920eda7d6a3cda753bdefd657321c99f448b02dd25
languageName: node
linkType: hard
"vitest@npm:^0.28.5":
version: 0.28.5
resolution: "vitest@npm:0.28.5"