Skip to content

Commit

Permalink
cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Rode committed Jul 10, 2017
1 parent c833c6d commit ddf7532
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 34 deletions.
8 changes: 8 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Frankenstein VR Release notes
## Version 0.1
- Global pipeline working
- Executable as jar, by jnlp and maven

## Upcomming changes
- Executable from CLI (java -jar target/frankenstein.jar ARGS...)

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<manifest.Codebase>*</manifest.Codebase>
<jnlp.URL>https://github.com/olir/Frankenstein/releases/download/${version}</jnlp.URL>
<mainClass>de.screenflow.frankenstein.fxml.Main</mainClass>
<mainClass>de.screenflow.frankenstein.Main</mainClass>
<jks.keystore>${project.basedir}/src/main/jnlp/dummy-keystore</jks.keystore>
<jks.keypass>pass01</jks.keypass>
<jks.storePass>pass01</jks.storePass>
Expand Down
78 changes: 76 additions & 2 deletions src/main/java/de/screenflow/frankenstein/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

import de.screenflow.frankenstein.vf.VideoFilter;
import de.screenflow.frankenstein.vf.VideoSource;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.stage.DirectoryChooser;

/**
* Data class
Expand All @@ -34,9 +38,10 @@ public class Configuration {
// Ini-File properties
Properties iniProperties = new Properties();

public final List<VideoFilter> filters = new ArrayList<VideoFilter>();
// current global Video Filters
private final List<VideoFilter> filters = new ArrayList<VideoFilter>();

public VideoSource source;
private VideoSource source;

public boolean doInput = true;
public boolean doOutput = true;
Expand Down Expand Up @@ -65,6 +70,59 @@ public class Configuration {

public SectionedProperties metadata = new SectionedProperties();

public static Configuration configure(String[] args) {
Configuration configuration = new Configuration(null);

// addTab(tabTestVideoGenerator);
// addTab(tabClone);
// addTab(tabVideoFileOutput);

// rTestVideoGenerator.setSelected(true);
// rCloneLR.setSelected(true);
// rNoAlignment.setSelected(true);
// rNoVR.setSelected(true);
// rVideoFileOutput.setSelected(true);

// tfPropertyInputDir.setText(configuration.getInputDir());

// tfPropertyTestScreenWidth.setText(String.valueOf(configuration.testScreenWidth));
// tfPropertyTestScreenHeight.setText(String.valueOf(configuration.testScreenHeight));
// if (configuration.anaglyphKeepWidth)
// rPropertyAnaglyphKeepWidth.setSelected(true);
// else
// rPropertyAnaglyphDoubleWidth.setSelected(true);

// if (configuration.ouAdjustSize)
// rPropertyOUAdjustSize.setSelected(true);
// else
// rPropertyOUReduceSize.setSelected(true);
//
// if (configuration.delayLeft)
// rDelayLeft.setSelected(true);
// else
// rDelayRight.setSelected(true);
//
// sliderVRShrink.setValue(configuration.vrModeShrinkFactor * 100.0);
// sliderVRShrink.valueProperty().addListener((observable, oldvalue, newvalue) -> {
// int newFactor = newvalue.intValue();
// configuration.vrModeShrinkFactor = ((float) newFactor) / 100.0f;
// lVRShrinkDisplay.setText(String.valueOf(newFactor) + '%');
// });
//
// if (configuration.vrModeShrinkOnly)
// vrModeFromVR.setSelected(true);
// else
// vrModeFromSBS.setSelected(true);
//
// sliderStereoPerspective.setValue(configuration.perspective);
return configuration;
}

/**
* Create empty configuration.
*
* @param helper ConfigHelper or null (non visual).
*/
public Configuration(ConfigHelper helper) {
String homeDir = System.getProperty("user.home");
outputVideo = new File(new File(System.getProperty("user.home")), "TestVideo.mp4").getAbsolutePath();
Expand All @@ -81,6 +139,8 @@ public Configuration(ConfigHelper helper) {
}

if (getFFmpegPath() == null) {
if (helper==null)
throw new RuntimeException("-ffmpegpath not set");
File dir = null;
while (dir == null) { // merciless inquisition
dir = helper.getFFmpegPath();
Expand All @@ -100,6 +160,8 @@ public Configuration(ConfigHelper helper) {
e.printStackTrace();
}
while (tf==null || !tf.canWrite()) { // merciless inquisition
if (helper==null)
throw new RuntimeException("-temppath not set");
tdf = helper.getTempPath();
try {
tf = File.createTempFile("Frankenstein", "tmp", tdf);
Expand Down Expand Up @@ -170,4 +232,16 @@ public interface ConfigHelper {
public File getTempPath();
}

public VideoSource getSource() {
return source;
}

public void setSource(VideoSource source) {
this.source = source;
}

public List<VideoFilter> getFilters() {
return filters;
}

}
27 changes: 27 additions & 0 deletions src/main/java/de/screenflow/frankenstein/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.screenflow.frankenstein;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;

public class Main {
public static void main(String[] args) {

System.out.println("Args: "+Arrays.toString(args));

Configuration c = Configuration.configure(args);

// todo

Class<?> fxMain;
try {
fxMain = Class.forName("de.screenflow.frankenstein.fxml.FxMain");
Class<?> parameterTypes [] = {};
Method main = fxMain.getDeclaredMethod("fxmain", parameterTypes);
Object [] invokeArgs = {};
main.invoke(fxMain, invokeArgs);
} catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
e.printStackTrace();
}
}
}
32 changes: 16 additions & 16 deletions src/main/java/de/screenflow/frankenstein/MovieProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public MovieProcessor(Configuration configuration) {
this.ffmpegPath = configuration.getFFmpegPath();
this.tempPath = new File(configuration.getTempPath());
this.configuration = configuration;
filters = configuration.filters;
filters = configuration.getFilters();
}

public void init(ProcessingListener l) {
Expand All @@ -70,7 +70,7 @@ public void init(ProcessingListener l) {
return;
}

frame = configuration.source.getFrame();
frame = configuration.getSource().getFrame();
if (frame != null && !frame.empty()) {
Mat newFrame = frame;
if (!filters.isEmpty()) {
Expand Down Expand Up @@ -101,7 +101,7 @@ public void init(ProcessingListener l) {
ffmpeg = new File(ffmpegPath, "\\bin\\ffmpeg.exe");

if (l != null)
l.videoStarted(configuration.source.getFrames(), configuration.source.getFps());
l.videoStarted(configuration.getSource().getFrames(), configuration.getSource().getFps());

currentPos = 1;
}
Expand Down Expand Up @@ -138,10 +138,10 @@ public boolean process(ProcessingListener l) {
Mat newFrame = null;

int i = 0;
while (!stopped && i < configuration.source.getFrames()) {
while (!stopped && i < configuration.getSource().getFrames()) {
i++;
currentPos = configuration.source.seek(i, l);
frame = configuration.source.getFrame();
currentPos = configuration.getSource().seek(i, l);
frame = configuration.getSource().getFrame();
if (frame != null && !frame.empty()) {
if (!filters.isEmpty()) {
newFrame = frame;
Expand Down Expand Up @@ -216,14 +216,14 @@ public static void stop() {
}

public boolean openInput(ProcessingListener l) {
configuration.source.open(l);
configuration.getSource().open(l);

movie_fps = configuration.source.getFps();
movie_frameCount = configuration.source.getFrames();
movie_w = configuration.source.getWidth();
movie_h = configuration.source.getHeight();
movie_fps = configuration.getSource().getFps();
movie_frameCount = configuration.getSource().getFrames();
movie_w = configuration.getSource().getWidth();
movie_h = configuration.getSource().getHeight();

frame = configuration.source.getFrame();
frame = configuration.getSource().getFrame();

System.out.println("Dimensions: " + (int) movie_w + " x " + (int) movie_h);
System.out.println("fps: " + movie_fps + " frameCount: " + (int) movie_frameCount);
Expand All @@ -232,7 +232,7 @@ public boolean openInput(ProcessingListener l) {
}

public void closeInput() {
configuration.source.close();
configuration.getSource().close();
}

public boolean openOutput(ProcessingListener l) {
Expand Down Expand Up @@ -303,10 +303,10 @@ public void seek(final ProcessingListener l, int frameId) {
l.seeking(0);

currentPos = 0;
configuration.source.reopen(l);
configuration.getSource().reopen(l);
}
currentPos = configuration.source.seek(frameId, l);
frame = configuration.source.getFrame();
currentPos = configuration.getSource().seek(frameId, l);
frame = configuration.getSource().getFrame();
if (frame != null && !frame.empty()) {
Mat newFrame = frame;
for (VideoFilter filter : filters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class ConfigurationSceneController {
@FXML
private Button doneButton;

private Main main;
private FxMain main;

private Stage stage;

Expand Down Expand Up @@ -289,27 +289,27 @@ public void changed(ObservableValue<? extends String> observable, String oldValu
});
}

public void configure(Main main, Stage stage) {
public void configure(FxMain main, Stage stage) {
this.main = main;
this.stage = stage;
}

@FXML
public void doneButtonPressed(ActionEvent event) {
List<VideoFilter> filters = configuration.filters;
List<VideoFilter> filters = configuration.getFilters();

filters.clear();

configuration.doInput = false;
if (rVideoFileInput.isSelected()) {
configuration.source = new VideoInput(configuration.getInputVideo());
configuration.setSource(new VideoInput(configuration.getInputVideo()));
configuration.doInput = true;
} else if (rSlideshowGenerator.isSelected()) {
configuration.source = new SlideShowInput(configuration.getInputDir());
filters.add((VideoFilter) configuration.source);
configuration.setSource(new SlideShowInput(configuration.getInputDir()));
filters.add((VideoFilter) configuration.getSource());
} else if (rTestVideoGenerator.isSelected()) {
configuration.source = new TestImageInput(configuration.testScreenWidth, configuration.testScreenHeight);
filters.add((VideoFilter) configuration.source);
configuration.setSource(new TestImageInput(configuration.testScreenWidth, configuration.testScreenHeight));
filters.add((VideoFilter) configuration.getSource());
} else {
throw new Error("No Input Method.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2017 Oliver Rode, https://github.com/olir/Frankenstein
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -29,7 +29,7 @@
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class Main extends Application {
public class FxMain extends Application {

private Stage theStage;
private Scene configurationScene, processingScene;
Expand Down Expand Up @@ -145,7 +145,8 @@ public void stop() {
MovieProcessor.stop();
}

public static void main(String[] args) {
public static void fxmain() {
String[] args = {};
launch(args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class ProcessingSceneController implements ProcessingListener {

private MovieProcessor processor;

private Main main;
private FxMain main;

// private Stage stage;

Expand Down Expand Up @@ -367,7 +367,7 @@ private int xForPosition(int p) {
return (int) ((editCanvas.getWidth() - 1) * (p - 1) / (frames - 1));
}

public void configure(Main main, Stage stage) {
public void configure(FxMain main, Stage stage) {
this.main = main;
// this.stage = stage;
}
Expand Down
Empty file.

0 comments on commit ddf7532

Please sign in to comment.