Skip to content

Commit

Permalink
fix bug on linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
DerCodeDev committed Nov 4, 2023
1 parent aef7cf4 commit 5ca6c25
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 23 deletions.
25 changes: 23 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.samir.vmdconverter</groupId>
<artifactId>VMDConverter</artifactId>
Expand All @@ -20,6 +20,26 @@
<artifactId>javafx-fxml</artifactId>
<version>21.0.1</version>
</dependency>


<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>21.0.1</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>21.0.1</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>21.0.1</version>
<classifier>mac</classifier>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -59,7 +79,8 @@
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>de.samir.vmdconverter.Main</mainClass>
</transformer>
</transformers>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/samir/vmdconverter/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void start(Stage stage) throws IOException {
}

stage.setResizable(false);
stage.setTitle("Coktel Vision AIO Converter 1.4");
stage.setTitle("Coktel Vision AIO Converter 1.4.1");
stage.setScene(scene);
stage.getIcons().add(new Image("https://i.ibb.co/6n3d45Y/cvac-icon.png"));
stage.show();
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/de/samir/vmdconverter/AppController.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ public void inputFieldBrowseButton(final ActionEvent actionEvent) {
final File selectedFile = fileChooser.showOpenDialog(App.getScene().getWindow());
if (selectedFile != null) {
inputField.setText(selectedFile.getAbsolutePath());
fileName = selectedFile.getName().replaceAll(".VMD", "").replace(".vmd", "");
fileName = selectedFile.getName().replaceAll(".IMD", "").replace(".imd", "");
fileName = selectedFile.getName().replaceAll(".DAT", "").replace(".dat", "");
fileName = selectedFile.getName().replaceAll(".STB", "").replace(".stb", "");
fileName = selectedFile.getName()
.replaceAll("(?i).vmd", "")
.replaceAll("(?i).imd", "")
.replaceAll("(?i).dat", "")
.replaceAll("(?i).stb", "");

}
}
Expand Down
29 changes: 13 additions & 16 deletions src/main/java/de/samir/vmdconverter/converter/VMDConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@

import de.samir.vmdconverter.AppController;

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;

public class VMDConverter {

public static void convertVideoMP4(String inputFilePath, String outputFilePath) {
String output_file = "\"" + outputFilePath + "/" + AppController.getFilename() + ".mp4\"";
String output_file = outputFilePath + File.separator + 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", inputFilePath, output_file);
String command = String.format("ffmpeg -i %s -codec:d vmdvideo -preset slow -crf 20 -codec:a aac -b:a 128k -movflags +faststart %s", inputFilePath, output_file);

try {
ProcessBuilder processBuilder = new ProcessBuilder(command.split(" "));
ProcessBuilder processBuilder = new ProcessBuilder(command.split("\\s+"));
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();

Expand All @@ -37,12 +34,12 @@ public static void convertVideoMP4(String inputFilePath, String outputFilePath)


public static void convertAudioMP3(String inputFilePath, String outputFilePath) {
String output_file = "\"" + outputFilePath + "/" + AppController.getFilename() + ".mp3\"";
String output_file = outputFilePath + File.separator + AppController.getFilename() + ".mp3";

String command = String.format("ffmpeg -i \"%s\" -vn -codec:a libmp3lame -qscale:a 2 %s", inputFilePath, output_file);
String command = String.format("ffmpeg -i %s -vn -codec:a libmp3lame -qscale:a 2 %s", inputFilePath, output_file);

try {
ProcessBuilder processBuilder = new ProcessBuilder(command.split(" "));
ProcessBuilder processBuilder = new ProcessBuilder(command.split("\\s+"));
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();

Expand All @@ -62,12 +59,12 @@ public static void convertAudioMP3(String inputFilePath, String outputFilePath)
}

public static void convertAudioWAV22050(String inputFilePath, String outputFilePath) {
String output_file = "\"" + outputFilePath + "/" + AppController.getFilename() + ".wav\"";
String output_file = outputFilePath + File.separator + AppController.getFilename() + ".wav";

String command = String.format("ffmpeg -i \"%s\" -acodec pcm_s16le -ac 1 -ar 22050 %s", inputFilePath, output_file);
String command = String.format("ffmpeg -i %s -acodec pcm_s16le -ac 1 -ar 22050 %s", inputFilePath, output_file);

try {
ProcessBuilder processBuilder = new ProcessBuilder(command.split(" "));
ProcessBuilder processBuilder = new ProcessBuilder(command.split("\\s"));
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();

Expand All @@ -89,12 +86,12 @@ public static void convertAudioWAV22050(String inputFilePath, String outputFileP


public static void convertAudioWAV44100(String inputFilePath, String outputFilePath) {
String output_file = "\"" + outputFilePath + "/" + AppController.getFilename() + ".wav\"";
String output_file = outputFilePath + File.separator + AppController.getFilename() + ".wav";

String command = String.format("ffmpeg -i \"%s\" -acodec pcm_s16le -ac 1 -ar 44100 %s", inputFilePath, output_file);
String command = String.format("ffmpeg -i %s -acodec pcm_s16le -ac 1 -ar 44100 %s", inputFilePath, output_file);

try {
ProcessBuilder processBuilder = new ProcessBuilder(command.split(" "));
ProcessBuilder processBuilder = new ProcessBuilder(command.split("\\s"));
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();

Expand Down

0 comments on commit 5ca6c25

Please sign in to comment.