Skip to content

Commit

Permalink
Functional, not automatically merging videos
Browse files Browse the repository at this point in the history
  • Loading branch information
RLLD576 committed Aug 14, 2024
1 parent 33f1e83 commit 2784a22
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/net/rober/mixin/ReplayScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ private void addButtonMixin(Args args) {
final GuiButton interpolateButton = new GuiButton().onClick(()-> {
List<GuiReplayViewer.GuiReplayEntry> selected = list.getSelected();
HashMap<String, Long> 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);
Expand All @@ -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);
}
Expand All @@ -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("");
Expand All @@ -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);
Expand Down

0 comments on commit 2784a22

Please sign in to comment.