mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-22 18:32:34 +01:00
improve random segment generation
make sure random segment start time is also randomized also clamp end time
This commit is contained in:
parent
4f018b0f12
commit
16c9f8b002
@ -359,8 +359,8 @@ export async function createRandomSegments(fileDuration) {
|
||||
const randomInRange = (min, max) => min + Math.random() * (max - min);
|
||||
|
||||
const edl = [];
|
||||
for (let start = 0; start < fileDuration && edl.length < maxSegments; start += randomInRange(gapMin, gapMax)) {
|
||||
const end = start + randomInRange(durationMin, durationMax);
|
||||
for (let start = randomInRange(gapMin, gapMax); start < fileDuration && edl.length < maxSegments; start += randomInRange(gapMin, gapMax)) {
|
||||
const end = Math.min(fileDuration, start + randomInRange(durationMin, durationMax));
|
||||
edl.push({ start, end });
|
||||
start = end;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user