From 2784a22846d2b9451297c4ebc8ff2b93e0a52436 Mon Sep 17 00:00:00 2001 From: Rob3r8 Date: Wed, 14 Aug 2024 15:53:14 +0200 Subject: [PATCH] Functional, not automatically merging videos --- src/main/java/net/rober/mixin/ReplayScreenMixin.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/rober/mixin/ReplayScreenMixin.java b/src/main/java/net/rober/mixin/ReplayScreenMixin.java index 79c4744..1f4b611 100644 --- a/src/main/java/net/rober/mixin/ReplayScreenMixin.java +++ b/src/main/java/net/rober/mixin/ReplayScreenMixin.java @@ -30,13 +30,14 @@ private void addButtonMixin(Args args) { final GuiButton interpolateButton = new GuiButton().onClick(()-> { List selected = list.getSelected(); HashMap replaysDurations = new HashMap<>(); - int durationsSum = 0; + long durationsSum = 0; for (GuiReplayViewer.GuiReplayEntry entry : selected) { try { ZipReplayFile replayFile = new ZipReplayFile(new ReplayStudio(),entry.file); long replayDuration = ((long) replayFile.getMetaData().getDuration())-3000L; replaysDurations.put(entry.file.getName(),replayDuration); durationsSum+=replayDuration; + replayFile.close(); } catch (IOException e) { throw new RuntimeException(e); @@ -61,6 +62,7 @@ private void addButtonMixin(Args args) { else { throw new RuntimeException("There isn't any camera keyframes to get the duration in the first replay"); } + replayFile.close(); } catch (IOException e) { throw new RuntimeException(e); } @@ -71,7 +73,7 @@ private void addButtonMixin(Args args) { try { ZipReplayFile replay = new ZipReplayFile(new ReplayStudio(),entry.file); long replayDuration = replaysDurations.get(entry.file.getName()); - double timelapseDuration = (double) replayDuration / (double )durationsSum * finalDuration; + long timelapseDuration = (long) ((double)replayDuration / ((double) durationsSum) * ((double) finalDuration)); SPTimeline spTimeline = new SPTimeline(); if(isFirst) { cameraTimeline = replay.getTimelines(new SPTimeline()).get(""); @@ -80,15 +82,17 @@ private void addButtonMixin(Args args) { } spTimeline = new SPTimeline(cameraTimeline); spTimeline.addTimeKeyframe(timePassed,3000); - timePassed+= (long) timelapseDuration; + timePassed+= timelapseDuration; spTimeline.addTimeKeyframe(timePassed, (int) (replayDuration+3000)); replay.writeTimelines(spTimeline,new HashMap<>(Map.of("",cameraTimeline))); replay.save(); + spTimeline.removeTimeKeyframe(timePassed-timelapseDuration); + spTimeline.removeTimeKeyframe(timePassed); } catch (IOException e) { throw new RuntimeException(e); } } - + }).setSize(150,20).setLabel("Interpolator"); GuiElement[] content = new GuiElement[]{(((GuiReplayViewer) (Object) this)).loadButton, interpolateButton}; args.set(1,content);