Skip to content

Commit

Permalink
added camera input
Browse files Browse the repository at this point in the history
  • Loading branch information
olir committed Jul 10, 2017
1 parent 8e8c129 commit 2f7cc21
Show file tree
Hide file tree
Showing 6 changed files with 267 additions and 132 deletions.
41 changes: 24 additions & 17 deletions src/main/java/de/screenflow/frankenstein/MovieProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ public void init(ProcessingListener l) {
Mat newFrame = frame;
if (!filters.isEmpty()) {
for (VideoFilter filter : filters) {
System.out.println("MovieProcessor configure " + filter.getClass().getName());
newFrame = filter.configure(newFrame);
}
}

newFrame = frame;
for (VideoFilter filter : filters) {
// System.out.println("MovieProcessor process
// "+filter.getClass().getName());
System.out.println("MovieProcessor process " + filter.getClass().getName());
newFrame = filter.process(newFrame, 1);
}
if (l != null)
Expand Down Expand Up @@ -125,7 +126,7 @@ public boolean process(ProcessingListener l) {
System.out
.print("Meta Data:\n===================\n" + configuration.metadata + "===================\n");

} else {
} else if (configuration.doOutput) {
// Create silent mp3
if (!new Task(ffmpeg.getAbsolutePath() + " -y -f lavfi -i anullsrc=r=44100:cl=mono -t "
+ (movie_frameCount / movie_fps) + " -q:a 9 -acodec libmp3lame "
Expand All @@ -138,16 +139,16 @@ public boolean process(ProcessingListener l) {
Mat newFrame = null;

int i = 0;
while (!stopped && i < configuration.getSource().getFrames()) {
while (!stopped
&& (configuration.getSource().getFrames() < 0 || i < configuration.getSource().getFrames())) {
i++;
currentPos = configuration.getSource().seek(i, l);
frame = configuration.getSource().getFrame();
if (frame != null && !frame.empty()) {
if (!filters.isEmpty()) {
newFrame = frame;
for (VideoFilter filter : filters) {
// System.out.println("MovieProcessor process
// "+filter.getClass().getName());
//System.out.println("MovieProcessor process"+filter.getClass().getName());
newFrame = filter.process(newFrame, i);
}
} else {
Expand Down Expand Up @@ -216,19 +217,24 @@ public static void stop() {
}

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

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

frame = configuration.getSource().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);
System.out.println("Dimensions: " + (int) movie_w + " x " + (int) movie_h);
System.out.println("fps: " + movie_fps + " frameCount: " + (int) movie_frameCount);

return true;
return true;
} catch (Throwable t) {
t.printStackTrace();
return false;
}
}

public void closeInput() {
Expand Down Expand Up @@ -283,8 +289,9 @@ public boolean configureOutput(ProcessingListener l) {
System.out.println("ConfigureOutput size=" + new Size(movie_w, movie_h) + " fps=" + movie_fps);

if (!outputVideo.isOpened()) {
System.err.println("Warning: VideoWriter - Could not open the output video for write. (MovieProcessor)");
// return false;
System.err
.println("Warning: VideoWriter - Could not open the output video for write. (MovieProcessor)");
// return false;
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import de.screenflow.frankenstein.vf.global.OutputSizeLimiter;
import de.screenflow.frankenstein.vf.global.RL2LR;
import de.screenflow.frankenstein.vf.global.StereoEffect;
import de.screenflow.frankenstein.vf.input.CameraInput;
import de.screenflow.frankenstein.vf.input.SlideShowInput;
import de.screenflow.frankenstein.vf.input.TestImageInput;
import de.screenflow.frankenstein.vf.input.VideoInput;
Expand Down Expand Up @@ -195,7 +196,10 @@ public class ConfigurationSceneController {
@FXML
Tab tabSlideshow;

@FXML RadioButton rDelay;
@FXML
RadioButton rDelay;

@FXML RadioButton rCameraInput;

/**
* Initialize method, automatically called by @{link FXMLLoader}
Expand Down Expand Up @@ -236,7 +240,7 @@ public File getTempPath() {
rVideoFileOutput.setSelected(true);

tfPropertyInputDir.setText(configuration.getInputDir());

tfPropertyTestScreenWidth.setText(String.valueOf(configuration.testScreenWidth));
tfPropertyTestScreenHeight.setText(String.valueOf(configuration.testScreenHeight));
if (configuration.anaglyphKeepWidth)
Expand Down Expand Up @@ -297,10 +301,8 @@ public void configure(FxMain main, Stage stage) {
@FXML
public void doneButtonPressed(ActionEvent event) {
List<VideoFilter> filters = configuration.getFilters();

filters.clear();

configuration.doInput = false;
if (rVideoFileInput.isSelected()) {
configuration.setSource(new VideoInput(configuration.getInputVideo()));
configuration.doInput = true;
Expand All @@ -310,6 +312,8 @@ public void doneButtonPressed(ActionEvent event) {
} else if (rTestVideoGenerator.isSelected()) {
configuration.setSource(new TestImageInput(configuration.testScreenWidth, configuration.testScreenHeight));
filters.add((VideoFilter) configuration.getSource());
} else if (rCameraInput.isSelected()) {
configuration.setSource(new CameraInput(0));
} else {
throw new Error("No Input Method.");
}
Expand Down Expand Up @@ -379,33 +383,36 @@ public void rActionVideoFileInput() {
}
}

@FXML public void rActionCameraInput() {
removeTab(tabVideoFileInput);
removeTab(tabSlideshow);
removeTab(tabTestVideoGenerator);
}

private File chooseInputVideo() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Video Input File");
fileChooser.getExtensionFilters().add(inputFileFilter);
String lastVideoDir = configuration.getInputVideoPath();

if (configuration.getInputVideo() != null) {
File f = new File(configuration.getInputVideo());
if (!f.isDirectory())
f = f.getParentFile();
if (f == null || !f.isDirectory())
f = new File(".");
fileChooser.setInitialDirectory(f);
}
else
if (lastVideoDir!=null)
} else if (lastVideoDir != null)
fileChooser.setInitialDirectory(new File(lastVideoDir));
else
fileChooser.setInitialDirectory(new File("."));



File file = fileChooser.showOpenDialog(stage);

if (file != null && file.exists() && !file.isDirectory()) {
configuration.setInputVideo(file.getAbsolutePath());
configuration.outputVideo = configuration.getInputVideo().substring(0, configuration.getInputVideo().lastIndexOf('.'))
+ "_edit" + ".mp4";
configuration.outputVideo = configuration.getInputVideo().substring(0,
configuration.getInputVideo().lastIndexOf('.')) + "_edit" + ".mp4";
tfPropertyOutputFile.setText(configuration.outputVideo);
main.setDocumentInTitle(file.getName());
if (rCloneLR.isSelected())
Expand All @@ -431,8 +438,7 @@ public void rActionSlideshowGenerator() {
rTestVideoGenerator.setSelected(true);
if (!rCloneLR.isSelected())
rCloneLR.setSelected(true);
}
else {
} else {
rNoNormalization.setSelected(true);
}
} else {
Expand All @@ -448,7 +454,7 @@ private File chooseSlideshowInputDir() {
DirectoryChooser dirChooser = new DirectoryChooser();
dirChooser.setTitle("Slides Directory");
String lastSlideDir = configuration.getInputDir();
if (lastSlideDir!=null)
if (lastSlideDir != null)
dirChooser.setInitialDirectory(new File(lastSlideDir));
if (configuration.getInputDir() != null) {
File f = new File(configuration.getInputDir());
Expand Down Expand Up @@ -660,4 +666,5 @@ public void tbActionStereoEffectFilterEnabled() {
sliderStereoPerspective.setDisable(!stereoEffectFilterEnabled.isSelected());
}


}

0 comments on commit 2f7cc21

Please sign in to comment.