-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/graphical/basics/presentation/RawVideoRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package graphical.basics.presentation; | ||
|
||
import codec.*; | ||
|
||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
import java.util.function.Consumer; | ||
|
||
public class RawVideoRecorder { | ||
final private PresentationConfig presentationConfig; | ||
|
||
private VideoCodec videoCodec; | ||
|
||
public RawVideoRecorder(Consumer<PresentationConfig> configurer) { | ||
this.presentationConfig = new PresentationConfig(); | ||
configurer.accept(presentationConfig); | ||
applyConfig(); | ||
start(); | ||
} | ||
|
||
public RawVideoRecorder(PresentationConfig presentationConfig) { | ||
this.presentationConfig = presentationConfig; | ||
applyConfig(); | ||
start(); | ||
} | ||
|
||
private void applyConfig() { | ||
if (presentationConfig.getCodec() != null) { | ||
switch (presentationConfig.getCodec()) { | ||
case JCODEC: | ||
this.videoCodec = new JCodec(); | ||
break; | ||
case RAW_IMAGE: | ||
this.videoCodec = new RawImageCodec(); | ||
break; | ||
case XUGGLE: | ||
this.videoCodec = new XugglerCodec(presentationConfig); | ||
break; | ||
case GIF: | ||
this.videoCodec = new GIFCodec(); | ||
} | ||
|
||
} else { | ||
this.videoCodec = new XugglerCodec(presentationConfig);//default | ||
} | ||
} | ||
|
||
private void start() { | ||
var executionPath = System.getProperty("user.dir"); | ||
File videoDir = new File(executionPath + "/video"); | ||
videoDir.mkdir(); | ||
|
||
File rawDir = new File(executionPath + "/video/raw"); | ||
rawDir.mkdir(); | ||
|
||
videoCodec.startNewVideo(executionPath + "/video/", "mv" + videoCodec.getFileFormat(), presentationConfig.getFramerate()); | ||
} | ||
|
||
public void addFrame(BufferedImage bufI) { | ||
videoCodec.addFrame(bufI); | ||
} | ||
|
||
public void saveVideo() { | ||
videoCodec.saveVideo(); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/graphical/basics/presentation/VideoMaker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package graphical.basics.presentation; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public abstract class VideoMaker extends Presentation { | ||
@Override | ||
protected void buildPresentation() { | ||
// do nothing | ||
} | ||
|
||
@Override | ||
public void build() { | ||
// do nothing | ||
} | ||
} |