From 0180865199ee49751439d05d08081661464abd61 Mon Sep 17 00:00:00 2001 From: Samir Date: Fri, 19 May 2023 23:02:28 +0200 Subject: [PATCH] Initial commit --- .gitignore | 38 +++++ README.md | 101 +++++++++++++ pom.xml | 51 +++++++ src/main/java/dev/samir/vmdconverter/App.java | 45 ++++++ .../dev/samir/vmdconverter/AppController.java | 136 ++++++++++++++++++ .../vmdconverter/converter/VMDConverter.java | 66 +++++++++ .../vmdconverter/utils/ConsoleOutput.java | 22 +++ .../dev/samir/vmdconverter/vmdconverter.fxml | 64 +++++++++ 8 files changed, 523 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/dev/samir/vmdconverter/App.java create mode 100644 src/main/java/dev/samir/vmdconverter/AppController.java create mode 100644 src/main/java/dev/samir/vmdconverter/converter/VMDConverter.java create mode 100644 src/main/java/dev/samir/vmdconverter/utils/ConsoleOutput.java create mode 100644 src/main/resources/dev/samir/vmdconverter/vmdconverter.fxml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..84ac61d --- /dev/null +++ b/README.md @@ -0,0 +1,101 @@ +# VMD Converter für Coktel Vision Spiele (Deutsch) +Entwickelt von DerCodeDev (Samir Ademi) & [CrystalBen](https://wiki.scummvm.org/index.php?title=User:CrystalBen) (Benjamin Funke) + +Coktel Vision war ein französicher Spieleentwickler und war bekannt für seine an Addy / Addy Junior / Adiboo Spielereihen. +der seine Spiele auf zwei verschiedenen Enginen entwickelt hat namens DEV6 und DEV7. + +# Anforderungen: +Du brauchst du nur ffmpeg +# Wie installiere ich ffmpeg auf Windows? +1. Lade ffmpeg [herunter](https://www.gyan.dev/ffmpeg/builds/) +2. Extrahiere die ZIP Datei (am besten auf die C: Parition) +3. Dann überprüfe ob alles richtig extrahiert wurde. +4. Nun öffene die Systemumgebungsvariablen. +5. Dann klicke auf Neu und gebe den Namen der Variable ein. +6. Nun klicke auf Datei durchsuchen und suche ffmpeg.exe und wähle diese aus. +7. dann drücke OK. +8. dann drücke OK erneut. +9. und nun zum allerletzen mal OK. +10. Nun öffene die CMD und gebe ffmpeg -version ein nun sollte eine Ausgabe erfolgen: ffmpeg version Versionsnummer + +# Wie installiere ich ffmpeg unter Linux? +1. Öffene ein Terminal und gebe sudo apt install ffmpeg -y ein. +2. Nach der Installation gebe ffmpeg -version ein +3. Diese Ausgabe sollte angezeigt werden: ffmpeg version und dann die Versionsnummer + +## Unterstütze Spiele: + +- Adi Jr. (DEV6) +- Addy Junior (DEV6) +- Addy 4 + +## Bald unterstützte Spiele: +- Adiboo 3 (DEV7) +- Addy 5 (DEV7) + +# VMD Converter for Coktel Vision Games (English) +Coktel Vision was a french Game Developer, Coktel was known for the familar Adi / Adiboo Games series. +Coktel had back then two Engines DEV6 and DEV7. +Developed by DerCodeDev & [CrystalBen](https://wiki.scummvm.org/index.php?title=User:CrystalBen) (Benjamin Funke) + +# Requirements: +you only need to have ffmpeg +# How to install ffmpeg on Windows? +1. Download ffmpeg [here](https://www.gyan.dev/ffmpeg/builds/) +2. Extract the Zip File into a Folder (recommended is to extract the Folder ffmpeg to the root of your C Partiton) +3. then check if you have in C:\ffmpeg\bin a ffmpeg.exe if so you can continue. +4. now went to System environment variables and press on Environmentvariables. +5. then press on New at the Section variables. +6. now under Name of Variable type ffmpeg and for Value of variable press on Browse File and search for ffmpeg.exe. +7. then press OK. +8. then press OK again. +9. and then for the very last time press OK. +10. now open a cmd and type fffmpeg -version, to check if it works now. you should get some output like: ffmpeg version and then the versionumber. + +# How to install ffmpeg under Linux? +1. open a Terminal and write sudo apt install ffmpeg -y +2. after the Installation test if ffmpeg was installed sucessfully via ffmpeg -version +3. you should get some output like: ffmpeg version and then your versionnumber + +## Supported Games: +- AJ's World of Discovery +- Adiboo 2 (DEV6) +- Adi 4.0 (DEV6) + +## Games that are supported soon: +- Adiboo 3 (DEV7) +- Addy 5 (DEV7) + +# VMD Converter pour Coktel Vision Jeux (Français) +Développé par DerCodeDev (Samir Ademi) & [CrystalBen](https://wiki.scummvm.org/index.php?title=User:CrystalBen) (Benjamin Funke) +Coktel Vision était francais Développeur pour Jeux. le de connu Adi / Adibou Jeux series devlopee a. +Coktel etait deux Game moteur DEV6 et DEV7 + +# Logiciels requis: +Vous n'avez besoin que de ffmpeg +# Comment Installer ffmpeg sur Windows? +1. Téléchargé ffmpeg [ici](https://www.gyan.dev/ffmpeg/builds/) +2. extrait ZIP Fichier (Recommende: C: Parition) +3. maintenant vérifier le Fichier correctement extrait. +4. Nun lancer System environment. +5. Cliquez sur Nouvelle et gebe den Namen de Variable ein. +6. Cliquez sur Parcourir le fichier et suche ffmpeg.exe choisir de maintenant le exe de. +7. Cliquez sur OK. +8. Cliquez sur OK en nouveau. +9. et maintenant cliquez sur OK pour la dernière fois. +10. Le lancer cmd entrer ffmpeg -version sortir comme: ffmpeg version numéro de version. + +# Comment Installer ffmpeg sur Linux? +1. lancer Terminal and write sudo apt install ffmpeg -y +2. entre maintenant ffmpeg -version +3. la sortie ressemble à ceci: ffmpeg version numéro de version. + + +## Supportée Jeux +- Adibou 1 +- Adibou 2 (DEV6) +- Adi 4 (DEV6) +- Adibou presente Dessin (DEV7) +## Bientot supportée Jeux +- Adibou 3 (DEV7) +- Adi 5 (DEV7) diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..dbad60f --- /dev/null +++ b/pom.xml @@ -0,0 +1,51 @@ + + 4.0.0 + org.example + VMDConverter + 1.0-SNAPSHOT + + UTF-8 + 11 + 11 + + + + org.openjfx + javafx-controls + 20 + + + org.openjfx + javafx-fxml + 20 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 11 + + + + org.openjfx + javafx-maven-plugin + 0.0.6 + + + + + default-cli + + dev.samir.vmdconverter.App + + + + + + + diff --git a/src/main/java/dev/samir/vmdconverter/App.java b/src/main/java/dev/samir/vmdconverter/App.java new file mode 100644 index 0000000..d6c4c17 --- /dev/null +++ b/src/main/java/dev/samir/vmdconverter/App.java @@ -0,0 +1,45 @@ +package dev.samir.vmdconverter; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.image.Image; +import javafx.stage.Stage; + +import java.io.IOException; + +/** + * JavaFX App + */ +public class App extends Application { + + private static Scene scene; + + @Override + public void start(Stage stage) throws IOException { + scene = new Scene(loadFXML("vmdconverter")); + stage.setResizable(false); + stage.setTitle("VMD Converter"); + stage.setScene(scene); + stage.getIcons().add(new Image("https://i.ibb.co/8mg6GLm/icon.png")); + stage.show(); + } + + static void setRoot(String fxml) throws IOException { + scene.setRoot(loadFXML(fxml)); + } + + private static Parent loadFXML(String fxml) throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml")); + return fxmlLoader.load(); + } + + public static void main(String[] args) { + launch(); + } + + public static Scene getScene() { + return scene; + } +} \ No newline at end of file diff --git a/src/main/java/dev/samir/vmdconverter/AppController.java b/src/main/java/dev/samir/vmdconverter/AppController.java new file mode 100644 index 0000000..37c0f83 --- /dev/null +++ b/src/main/java/dev/samir/vmdconverter/AppController.java @@ -0,0 +1,136 @@ +package dev.samir.vmdconverter; + +import dev.samir.vmdconverter.utils.ConsoleOutput; +import javafx.concurrent.Task; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.*; +import javafx.stage.DirectoryChooser; +import javafx.stage.FileChooser; +import dev.samir.vmdconverter.converter.VMDConverter; + +import java.io.File; +import java.io.PrintStream; + + +public class AppController { + + private static String fileName; + + @FXML + private TextField inputField; + + @FXML + private TextField outputField; + + @FXML + private RadioButton rb3; + + @FXML + private RadioButton rb4; + + @FXML + private TextArea consoleLog; + + + @FXML + public void inputFieldBrowseButton(final ActionEvent actionEvent) { + actionEvent.consume(); + final FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle("Select your VMD File!"); + fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("VMD File (*.vmd)", "*.vmd")); + final File selectedFile = fileChooser.showOpenDialog(App.getScene().getWindow()); + if (selectedFile != null) { + inputField.setText(selectedFile.getAbsolutePath()); + fileName = selectedFile.getName().replaceAll(".VMD", "").replace(".vmd", ""); + + } + } + + @FXML + public void outputFieldBrowseButton(final ActionEvent actionEvent) { + actionEvent.consume(); + final DirectoryChooser directoryChooser = new DirectoryChooser(); + directoryChooser.setTitle("Select your output file location!"); + final File selectedDirectory = directoryChooser.showDialog(App.getScene().getWindow()); + + if (selectedDirectory != null) { + outputField.setText(selectedDirectory.getAbsolutePath()); + } + } + + @FXML + public void initialize() { + ConsoleOutput consoleOutput = new ConsoleOutput(consoleLog); + PrintStream consolePrintStream = new PrintStream(consoleOutput); + System.setOut(consolePrintStream); + } + + + @FXML + public void startButton(final ActionEvent actionEvent) { + actionEvent.consume(); + if (inputField.getText().isEmpty() || inputField.getText() == null) { + showErrorMessage(); + return; + } + if (outputField.getText().isEmpty() || outputField.getText() == null) { + showErrorMessage(); + return; + } + if (!rb3.isSelected() && !rb4.isSelected()) { + showErrorMessage(); + return; + } + + if (rb4.isSelected()) { + Task conversionTask = new Task<>() { + @Override + protected Void call() throws Exception { + VMDConverter.convertVideoMP4(inputField.getText(), outputField.getText()); + return null; + } + }; + ConsoleOutput consoleOutput = new ConsoleOutput(consoleLog); + PrintStream consolePrintStream = new PrintStream(consoleOutput); + System.setOut(consolePrintStream); + + Thread conversionThread = new Thread(conversionTask); + conversionThread.setDaemon(true); + conversionThread.start(); + + return; + } + if (rb3.isSelected()) { + Task conversionTask = new Task<>() { + @Override + protected Void call() throws Exception { + VMDConverter.convertVideoMP3(inputField.getText(), outputField.getText()); + return null; + } + }; + ConsoleOutput consoleOutput = new ConsoleOutput(consoleLog); + PrintStream consolePrintStream = new PrintStream(consoleOutput); + System.setOut(consolePrintStream); + + Thread conversionThread = new Thread(conversionTask); + conversionThread.setDaemon(true); + conversionThread.start(); + + } + } + + + private void showErrorMessage() { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("Error Dialog"); + alert.setHeaderText("Look, an Error Dialog"); + alert.setContentText("Please fill out all fields properly."); + alert.showAndWait(); + } + + public static String getFilename() { + return fileName; + } +} + diff --git a/src/main/java/dev/samir/vmdconverter/converter/VMDConverter.java b/src/main/java/dev/samir/vmdconverter/converter/VMDConverter.java new file mode 100644 index 0000000..23b4b07 --- /dev/null +++ b/src/main/java/dev/samir/vmdconverter/converter/VMDConverter.java @@ -0,0 +1,66 @@ +package dev.samir.vmdconverter.converter; + + +import dev.samir.vmdconverter.AppController; + +import java.io.IOException; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class VMDConverter { + + public static void convertVideoMP4(String inputFilePath, String outputFilePath) { + String input_file = inputFilePath; + String output_file = "\"" + outputFilePath + "/" + AppController.getFilename() + ".mp4\""; + + String command = String.format("ffmpeg -i \"%s\" -codec:d vmdvideo -preset slow -crf 20 -codec:a aac -b:a 128k -movflags +faststart %s", input_file, output_file); + + try { + ProcessBuilder processBuilder = new ProcessBuilder(command.split(" ")); + processBuilder.redirectErrorStream(true); + Process process = processBuilder.start(); + + InputStream inputStream = process.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + + int exitCode = process.waitFor(); + System.out.println("FFmpeg command execution completed with exit code: " + exitCode); + + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + } + + + public static void convertVideoMP3(String inputFilePath, String outputFilePath) { + String input_file = inputFilePath; + String output_file = "\"" + outputFilePath + "/" + AppController.getFilename() + ".mp3\""; + + String command = String.format("ffmpeg -i \"%s\" -vn -codec:a libmp3lame -qscale:a 2 %s", input_file, output_file); + + try { + ProcessBuilder processBuilder = new ProcessBuilder(command.split(" ")); + processBuilder.redirectErrorStream(true); + Process process = processBuilder.start(); + + InputStream inputStream = process.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + + int exitCode = process.waitFor(); + System.out.println("FFmpeg command execution completed with exit code: " + exitCode); + + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/src/main/java/dev/samir/vmdconverter/utils/ConsoleOutput.java b/src/main/java/dev/samir/vmdconverter/utils/ConsoleOutput.java new file mode 100644 index 0000000..ba6eb0b --- /dev/null +++ b/src/main/java/dev/samir/vmdconverter/utils/ConsoleOutput.java @@ -0,0 +1,22 @@ +package dev.samir.vmdconverter.utils; + +import javafx.application.Platform; +import javafx.scene.control.TextArea; + +import java.io.OutputStream; + +public class ConsoleOutput extends OutputStream { + + private final TextArea consoleLog; + + public ConsoleOutput(TextArea consoleLog) { + this.consoleLog = consoleLog; + } + + @Override + public void write(int b) { + char character = (char) b; + Platform.runLater(() -> consoleLog.appendText(String.valueOf(character))); + } +} + diff --git a/src/main/resources/dev/samir/vmdconverter/vmdconverter.fxml b/src/main/resources/dev/samir/vmdconverter/vmdconverter.fxml new file mode 100644 index 0000000..e14ecc0 --- /dev/null +++ b/src/main/resources/dev/samir/vmdconverter/vmdconverter.fxml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + +