Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
26ec5d2782 | |||
21ea8b3caf | |||
12ab510224 | |||
f861445697 | |||
ffb7d2d9f1 | |||
3742c44c40 |
@ -2,7 +2,7 @@ pipeline:
|
||||
build:
|
||||
image: maven:3-jdk-11
|
||||
commands:
|
||||
- mvn clean package
|
||||
- mvn clean compile assembly:single
|
||||
|
||||
gitea_release:
|
||||
image: plugins/gitea-release
|
||||
|
43
README.md
43
README.md
@ -1,3 +1,42 @@
|
||||
# dragoon
|
||||
# Dragoon
|
||||
|
||||
Bit Goblin video transcoder
|
||||
The Bit Goblin video transcoder.
|
||||
|
||||
## Building
|
||||
|
||||
Currently this project is targeting Java 11 LTS and uses Maven to manage the software lifecycle. Thus, you must have a Java 11 JDK and Maven installed to build this project.
|
||||
|
||||
*NOTE:* The targeted Java version will likely change to 17 LTS soon.
|
||||
|
||||
### Ubuntu
|
||||
|
||||
`sudo apt install openjdk-11-jdk maven`
|
||||
|
||||
### Red Hat/Almalinux
|
||||
|
||||
`sudo dnf install java-11-openjdk-devel maven`
|
||||
|
||||
### Actually Building
|
||||
|
||||
Now that the needed tools are installed, you should be able to build this project. To build a JAR file with it's dependencies included:
|
||||
|
||||
`mvn clean compile assembly:single`
|
||||
|
||||
Then you can run the transcoder:
|
||||
|
||||
`java -jar target/Dragon-VERSION-jar-with-dependencies.jar`
|
||||
|
||||
## Configuration
|
||||
|
||||
If you were paying attention to Dragoon's output, you would have noticed that it failed with a complaint about not finding a configuration file. The location might move in the future or even be configurable, but for now you need to have a TOML file located at `~/.config/dragoon.toml` with at minimum the following contents:
|
||||
|
||||
```toml
|
||||
# This example transcodes footage to DNxHD 1080p60 for use in video editors like DaVinci Resolve.
|
||||
[transcoder]
|
||||
repo_path = '~/videos' # location of the videos to transcode
|
||||
video_format = 'mov' # video container format
|
||||
video_codec = 'dnxhd' # video codec to use
|
||||
video_parameters = 'scale=1920x1080,fps=60,format=yuv422p' # video extra format parameters flag - this will be broken later into separate attributes
|
||||
video_profile = 'dnxhr_hq' # DNxHD has multiple presets for various video qualities
|
||||
audio_codec = 'pcm_s16le' # audio codec to use
|
||||
```
|
||||
|
28
pom.xml
28
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>tech.bitgoblin</groupId>
|
||||
<artifactId>Dragoon</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<version>0.1.1</version>
|
||||
|
||||
<name>Dragoon</name>
|
||||
<url>https://www.bitgoblin.tech</url>
|
||||
@ -18,6 +18,11 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.tomlj</groupId>
|
||||
<artifactId>tomlj</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
@ -63,6 +68,27 @@
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>tech.bitgoblin.App</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package tech.bitgoblin;
|
||||
|
||||
import tech.bitgoblin.config.Config;
|
||||
import tech.bitgoblin.video.Transcoder;
|
||||
|
||||
/**
|
||||
@ -8,9 +9,13 @@ import tech.bitgoblin.video.Transcoder;
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final String configFile = "~/.config/dragoon.toml";
|
||||
|
||||
public static void main(String[] args) {
|
||||
// read our config file
|
||||
Config c = new Config(configFile);
|
||||
// create new Transcoder object and start the service
|
||||
Transcoder t = new Transcoder("~/dragoon");
|
||||
Transcoder t = new Transcoder(c);
|
||||
t.transcode();
|
||||
}
|
||||
|
||||
|
42
src/main/java/tech/bitgoblin/config/Config.java
Normal file
42
src/main/java/tech/bitgoblin/config/Config.java
Normal file
@ -0,0 +1,42 @@
|
||||
package tech.bitgoblin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import org.tomlj.Toml;
|
||||
import org.tomlj.TomlParseResult;
|
||||
import tech.bitgoblin.io.IOUtils;
|
||||
|
||||
public class Config {
|
||||
|
||||
private final String configPath;
|
||||
private TomlParseResult result;
|
||||
|
||||
public Config(String path) {
|
||||
this.configPath = IOUtils.resolveTilda(path);
|
||||
// parse config file
|
||||
try {
|
||||
this.parseConfig();
|
||||
} catch (IOException e) {
|
||||
System.out.println("Unable to read config file; please check that " + this.configPath + " is available.");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String key) {
|
||||
return this.result.getString(key);
|
||||
}
|
||||
|
||||
public boolean contains(String key) {
|
||||
return this.result.contains(key);
|
||||
}
|
||||
|
||||
private void parseConfig() throws IOException {
|
||||
// parse config file
|
||||
Path source = Paths.get(this.configPath);
|
||||
this.result = Toml.parse(source);
|
||||
this.result.errors().forEach(error -> System.err.println(error.toString()));
|
||||
}
|
||||
|
||||
}
|
@ -12,22 +12,22 @@ import java.nio.file.Paths;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import tech.bitgoblin.config.Config;
|
||||
import tech.bitgoblin.io.IOUtils;
|
||||
|
||||
public class Transcoder {
|
||||
|
||||
private String repo_dir;
|
||||
private Config config;
|
||||
private String ffmpeg_path = "/usr/bin/ffmpeg";
|
||||
|
||||
// only define the working directory; use default FFMPEG path
|
||||
public Transcoder(String repo_dir) {
|
||||
this.repo_dir = IOUtils.resolveTilda(repo_dir);
|
||||
this.initDirectory();
|
||||
public Transcoder(Config config) {
|
||||
this.config = config;
|
||||
this.repo_dir = IOUtils.resolveTilda(this.config.getString("transcoder.repo_path"));
|
||||
if (this.config.contains("transcoder.ffmpeg_path")) {
|
||||
this.ffmpeg_path = this.config.getString("transcoder.ffmpeg_path");
|
||||
}
|
||||
// define a custom FFMPEG binary path
|
||||
public Transcoder(String repo_dir, String ffmpeg_path) {
|
||||
this.repo_dir = IOUtils.resolveTilda(repo_dir);
|
||||
this.ffmpeg_path = ffmpeg_path;
|
||||
this.initDirectory();
|
||||
}
|
||||
|
||||
@ -48,11 +48,11 @@ public class Transcoder {
|
||||
String cmd = String.format("%s -i %s -y -f %s -c:v %s -vf %s -profile:v %s -c:a %s %s",
|
||||
this.ffmpeg_path, // FFMPEG binary path
|
||||
f.toString(), // input file
|
||||
"mov",
|
||||
"dnxhd", // video codec
|
||||
"scale=1920x1080,fps=60,format=yuv422p", // video format
|
||||
"dnxhr_hq", // video profile
|
||||
"pcm_s16le", // audio codec
|
||||
this.config.getString("transcoder.video_format"), // video container format
|
||||
this.config.getString("transcoder.video_codec"), // video codec
|
||||
this.config.getString("transcoder.video_parameters"), // video format
|
||||
this.config.getString("transcoder.video_profile"), // video profile
|
||||
this.config.getString("transcoder.audio_codec"), // audio codec
|
||||
outputPath // output file path
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user