6 Commits

Author SHA1 Message Date
26ec5d2782 Updated version info to v0.1.1
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-05-02 23:50:35 -04:00
21ea8b3caf Added ability to configure the transcoding job with some parameters in dragoon.toml
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-05-02 23:46:21 -04:00
12ab510224 Updated README with info on how to build and configure this software
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-05-02 18:37:23 -04:00
f861445697 Added Maven step to compile a .jar file with all dependencies (for easy deployment); Added code to define the FFMPEG binary path and video repository through a TOML file
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-05-02 16:15:01 -04:00
ffb7d2d9f1 Added a check for the config file
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-05-01 23:02:31 -04:00
3742c44c40 Added ability to load in a TOML file for config
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-05-01 20:36:24 -04:00
6 changed files with 206 additions and 94 deletions

View File

@ -2,7 +2,7 @@ pipeline:
build: build:
image: maven:3-jdk-11 image: maven:3-jdk-11
commands: commands:
- mvn clean package - mvn clean compile assembly:single
gitea_release: gitea_release:
image: plugins/gitea-release image: plugins/gitea-release

View File

@ -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
```

180
pom.xml
View File

@ -1,86 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <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/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>tech.bitgoblin</groupId> <groupId>tech.bitgoblin</groupId>
<artifactId>Dragoon</artifactId> <artifactId>Dragoon</artifactId>
<version>0.1.0</version> <version>0.1.1</version>
<name>Dragoon</name> <name>Dragoon</name>
<url>https://www.bitgoblin.tech</url> <url>https://www.bitgoblin.tech</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.tomlj</groupId>
<artifactId>junit</artifactId> <artifactId>tomlj</artifactId>
<version>4.11</version> <version>1.0.0</version>
<scope>test</scope> </dependency>
</dependency> <dependency>
</dependencies> <groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build> <build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins> <plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin> <plugin>
<artifactId>maven-clean-plugin</artifactId> <artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version> <version>3.1.0</version>
</plugin> </plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin> <plugin>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version> <version>3.0.2</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version> <version>3.8.0</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version> <version>2.22.1</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version> <version>3.0.2</version>
<configuration> <configuration>
<!-- DO NOT include log4j.properties file in your Jar --> <!-- DO NOT include log4j.properties file in your Jar -->
<excludes> <excludes>
<exclude>**/log4j.properties</exclude> <exclude>**/log4j.properties</exclude>
</excludes> </excludes>
<archive> <archive>
<manifest> <manifest>
<!-- Jar file entry point --> <!-- Jar file entry point -->
<mainClass>tech.bitgoblin.App</mainClass> <mainClass>tech.bitgoblin.App</mainClass>
</manifest> </manifest>
</archive> </archive>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-install-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version> <executions>
</plugin> <execution>
<plugin> <phase>package</phase>
<artifactId>maven-deploy-plugin</artifactId> <goals>
<version>2.8.2</version> <goal>single</goal>
</plugin> </goals>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> </execution>
<plugin> </executions>
<artifactId>maven-site-plugin</artifactId> <configuration>
<version>3.7.1</version> <archive>
</plugin> <manifest>
<plugin> <mainClass>tech.bitgoblin.App</mainClass>
<artifactId>maven-project-info-reports-plugin</artifactId> </manifest>
<version>3.0.0</version> </archive>
</plugin> <descriptorRefs>
</plugins> <descriptorRef>jar-with-dependencies</descriptorRef>
</pluginManagement> </descriptorRefs>
</build> </configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project> </project>

View File

@ -1,5 +1,6 @@
package tech.bitgoblin; package tech.bitgoblin;
import tech.bitgoblin.config.Config;
import tech.bitgoblin.video.Transcoder; import tech.bitgoblin.video.Transcoder;
/** /**
@ -8,9 +9,13 @@ import tech.bitgoblin.video.Transcoder;
*/ */
public class App { public class App {
private static final String configFile = "~/.config/dragoon.toml";
public static void main(String[] args) { public static void main(String[] args) {
// read our config file
Config c = new Config(configFile);
// create new Transcoder object and start the service // create new Transcoder object and start the service
Transcoder t = new Transcoder("~/dragoon"); Transcoder t = new Transcoder(c);
t.transcode(); t.transcode();
} }

View 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()));
}
}

View File

@ -12,22 +12,22 @@ import java.nio.file.Paths;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import tech.bitgoblin.config.Config;
import tech.bitgoblin.io.IOUtils; import tech.bitgoblin.io.IOUtils;
public class Transcoder { public class Transcoder {
private String repo_dir; private String repo_dir;
private Config config;
private String ffmpeg_path = "/usr/bin/ffmpeg"; private String ffmpeg_path = "/usr/bin/ffmpeg";
// only define the working directory; use default FFMPEG path // only define the working directory; use default FFMPEG path
public Transcoder(String repo_dir) { public Transcoder(Config config) {
this.repo_dir = IOUtils.resolveTilda(repo_dir); this.config = config;
this.initDirectory(); this.repo_dir = IOUtils.resolveTilda(this.config.getString("transcoder.repo_path"));
} if (this.config.contains("transcoder.ffmpeg_path")) {
// define a custom FFMPEG binary path this.ffmpeg_path = this.config.getString("transcoder.ffmpeg_path");
public Transcoder(String repo_dir, String ffmpeg_path) { }
this.repo_dir = IOUtils.resolveTilda(repo_dir);
this.ffmpeg_path = ffmpeg_path;
this.initDirectory(); 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", 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 this.ffmpeg_path, // FFMPEG binary path
f.toString(), // input file f.toString(), // input file
"mov", this.config.getString("transcoder.video_format"), // video container format
"dnxhd", // video codec this.config.getString("transcoder.video_codec"), // video codec
"scale=1920x1080,fps=60,format=yuv422p", // video format this.config.getString("transcoder.video_parameters"), // video format
"dnxhr_hq", // video profile this.config.getString("transcoder.video_profile"), // video profile
"pcm_s16le", // audio codec this.config.getString("transcoder.audio_codec"), // audio codec
outputPath // output file path outputPath // output file path
); );