Compare commits

..

37 Commits

Author SHA1 Message Date
2a007df722 Version bump to v0.3.12
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-04-19 14:57:41 -04:00
Gregory Ballantine
73b15ce781 Separated the resolution, color, and frame rate options in the config file
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-04-19 14:53:59 -04:00
3e50146f5e Updatd README with RHEL installation instructions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-03-24 12:45:00 -04:00
5d36c40508 Fixed RHEL ffmpeg requirement; version bump to v0.3.11
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2023-03-24 12:33:00 -04:00
12f81cb014 Version bump to v0.3.10
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-03-24 11:09:20 -04:00
8c0c52c736 Changed how the input and output files get added to the command array to better handle spaces in file names
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-02-18 22:49:18 -05:00
bd8e36d893 Version bump to v0.3.9
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-01-25 14:04:03 -05:00
dacd86039d Fixed typo in dragoon log path for packages
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-25 14:03:47 -05:00
af41be829a Fixed error in log4j2.xml path
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-01-25 13:56:46 -05:00
1c08196104 Version bump to v0.3.8
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2023-01-25 13:53:48 -05:00
7b23fa248b Fixed path for log4j2.xml in packaging
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-25 13:53:26 -05:00
095e5c2a84 Fixed typo in path
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-01-25 13:48:35 -05:00
0c77a7ab04 Fixed CmdTest
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2023-01-25 13:45:02 -05:00
cfb1d09eb7 Version bump to v0.3.7
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/tag/woodpecker Pipeline failed
2023-01-25 13:42:52 -05:00
bd4117df38 Fixed a few housekeeping things to make the linux packages more plug-and-play
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-01-25 13:42:36 -05:00
0eaf18822b Version bump to v0.3.6
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-01-25 13:27:58 -05:00
7bdd4a5dfb Added log4j2.xml to linux packages to fix the deployment
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-25 13:27:16 -05:00
ea6e6c95e1 Updated woodpecker
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-01-25 11:54:31 -05:00
c7f9c4cf73 Fixed woodpecker config
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2023-01-25 11:38:48 -05:00
ce9efc463d Version bump to v0.3.5
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2023-01-25 11:09:28 -05:00
879ff8f8f4 Updated woodpecker config to copy packages to the local repo
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-25 11:08:38 -05:00
f132861cbc Fixed log4j class not found error; Updated log4j version
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-01-25 10:14:50 -05:00
47e8ec4f43 Version bump to v0.3.4
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-01-25 01:02:10 -05:00
c0c96c7a51 Updated documentation to use 17
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-25 00:57:06 -05:00
8cb640d804 Updated woodpecker config to use eclipse temurin Alpine image
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-01-24 23:18:33 -05:00
1189f4b61c Changed dnf commands to apt for the new image
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-01-15 17:07:25 -05:00
0f5b9eb45a Changed to using the eclipse temurin JDK builds
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-01-15 17:04:52 -05:00
9a567b7178 Version bump to v0.3.3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-08-30 00:40:24 -04:00
88f63e040e Updated woodpecker config for new OpenJDK docker image
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-30 00:37:11 -04:00
aabf1d49a7 Updating target to Java 17 (using openjdk 18)
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-08-30 00:25:22 -04:00
3b789eb623 Updating target to Java 17
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-08-30 00:08:18 -04:00
ad0115e5f2 Fixed the install dependencies for the generated .deb package
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-07-17 20:13:22 -04:00
3c6079807e Version bump to v0.3.2
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-07-17 14:18:56 -04:00
b21d98ef73 Updated woodpecker config to skip tests on packaging (since they would've already been run earlier)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-07-17 14:14:55 -04:00
2e55876076 Changed the default config location to /etc/dragoon/config.toml; added a CLI option (-c) to specify a different config file.
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2022-07-17 14:04:48 -04:00
dad3e6c1cf Added .deb and .rpm package build step
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-07-17 13:32:58 -04:00
8c36855593 Removed some unused imports; closed an open file in a unit test
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-06-16 00:12:16 -04:00
17 changed files with 460 additions and 114 deletions

View File

@ -1,15 +1,23 @@
pipeline: pipeline:
test: test:
image: maven:3-jdk-11 image: maven:3-eclipse-temurin-17-alpine
commands: commands:
- apt update && apt install -y lsof - apk add lsof
- mvn test - mvn test
build: build:
image: maven:3-jdk-11 image: maven:3-eclipse-temurin-17-alpine
commands: commands:
- mvn clean compile assembly:single - mvn clean compile assembly:single
package:
image: maven:3-eclipse-temurin-17-alpine
commands:
- apk add rpm
- mvn clean compile package -Dmaven.test.skip
when:
event: tag
gitea_release: gitea_release:
image: plugins/gitea-release image: plugins/gitea-release
settings: settings:
@ -18,6 +26,54 @@ pipeline:
base_url: https://git.metaunix.net base_url: https://git.metaunix.net
title: "${CI_COMMIT_TAG}" title: "${CI_COMMIT_TAG}"
files: files:
- target/Dragoon-*.jar - target/dragoon-*.jar
- target/dragoon-*.deb
- target/rpm/dragoon/RPMS/noarch/dragoon-*.rpm
when:
event: tag
copy_deb_package:
image: appleboy/drone-scp
settings:
host: "repo.int.metaunix.net"
username:
from_secret: repo_admin
password:
from_secret: repo_password
port: 22
target: /srv/repo/apt/dragoon/
source: target/dragoon-*.deb
strip_components: 1
when:
event: tag
copy_rpm_package:
image: appleboy/drone-scp
settings:
host: "repo.int.metaunix.net"
username:
from_secret: repo_admin
password:
from_secret: repo_password
port: 22
target: /srv/repo/dnf/dragoon/
source: target/rpm/dragoon/RPMS/noarch/dragoon-*.rpm
strip_components: 5
when:
event: tag
update_repos:
image: appleboy/drone-ssh
settings:
host:
- repo.int.metaunix.net
username:
from_secret: repo_admin
password:
from_secret: repo_password
port: 22
command_timeout: 2m
script:
- sudo /home/xadmin/scripts/update_repo.sh
when: when:
event: tag event: tag

View File

@ -2,19 +2,41 @@
The Bit Goblin video transcoder. The Bit Goblin video transcoder.
## Installing from RPM
Installing from the Bit Goblin repository is easy! Add the following repo file to `/etc/yum.repos.d/bitgoblin.repo`:
```
[bitgoblin]
name=Bit Goblin repository
baseurl=http://repo.metaunix.net/dnf
enabled=1
gpgcheck=0
```
Update your package sources just to make sure all was added properly:
```
dnf updateinfo
```
Then install dragoon! Use the command below if you DON'T want DNF to install a bunch of unnecessary stuff to meet OpenJDK's weak dependencies; otherwise a regular `dnf install dragoon` is fine:
```
dnf --setopt=install_weak_deps=False --best install dragoon
```
## Building ## 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. Currently this project is targeting Java 17 LTS and uses Maven to manage the software lifecycle. Thus, you must have a Java 17 JDK and Maven installed to build this project.
*NOTE:* The targeted Java version will likely change to 17 LTS soon.
### Ubuntu ### Ubuntu
`sudo apt install openjdk-11-jdk maven` `sudo apt install openjdk-17-jdk maven`
### Red Hat/Almalinux ### Red Hat/Almalinux
`sudo dnf install java-11-openjdk-devel maven` `sudo dnf install java-17-openjdk-devel maven`
### Actually Building ### Actually Building

166
pom.xml
View File

@ -5,19 +5,48 @@
<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.3.1</version> <version>0.3.12</version>
<name>Dragoon</name> <name>Dragoon</name>
<url>https://www.bitgoblin.tech</url> <url>https://www.bitgoblin.tech</url>
<description>Automated video transcoder service.</description>
<inceptionYear>2022</inceptionYear>
<organization>
<name>Bit Goblin</name>
<url>https://www.bitgoblin.tech</url>
</organization>
<developers>
<developer>
<id>gballantine</id>
<name>Gregory Ballantine</name>
<email>gballantine@bitgoblin.tech</email>
</developer>
</developers>
<licenses>
<license>
<name>BSD</name>
<url>https://opensource.org/licenses/BSD-2-Clause</url>
<distribution>repo</distribution>
<comments>Simplified BSD license.</comments>
</license>
</licenses>
<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>17</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.3.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.tomlj</groupId> <groupId>org.tomlj</groupId>
<artifactId>tomlj</artifactId> <artifactId>tomlj</artifactId>
@ -26,12 +55,12 @@
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId> <artifactId>log4j-api</artifactId>
<version>2.17.2</version> <version>2.19.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId> <artifactId>log4j-core</artifactId>
<version>2.17.2</version> <version>2.19.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -42,7 +71,6 @@
</dependencies> </dependencies>
<build> <build>
<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>
@ -99,6 +127,129 @@
</descriptorRefs> </descriptorRefs>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>com.aerse.maven</groupId>
<artifactId>deb-maven-plugin</artifactId>
<version>1.16</version>
<executions>
<execution>
<id>package</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<unixUserId>dragoon</unixUserId>
<unixGroupId>dragoon</unixGroupId>
<debBaseDir>${project.basedir}/src/build/deb</debBaseDir>
<installDir>/opt</installDir>
<osDependencies>
<openjdk-17-jre></openjdk-17-jre>
<ffmpeg></ffmpeg>
</osDependencies>
<javaServiceWrapper>false</javaServiceWrapper>
<generateVersion>false</generateVersion>
<fileSets>
<fileSet>
<source>${basedir}/src/build/deb</source>
<target>/</target>
</fileSet>
<fileSet>
<source>${basedir}/target/dragoon-${project.version}-jar-with-dependencies.jar</source>
<target>/opt/dragoon/dragoon.jar</target>
</fileSet>
</fileSets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<id>generate-rpm</id>
<goals>
<goal>rpm</goal>
</goals>
</execution>
</executions>
<configuration>
<license>BSD 2-Clause</license>
<group>Applications/Multimedia</group>
<icon>src/main/resources/icon.gif</icon>
<packager>Bit Goblin</packager>
<prefix>/opt</prefix>
<changelogFile>${project.basedir}/src/build/changelog.txt</changelogFile>
<targetOs>linux</targetOs>
<mappings>
<mapping>
<directory>/opt/dragoon</directory>
<filemode>755</filemode>
<username>dragoon</username>
<groupname>dragoon</groupname>
</mapping>
<mapping>
<directory>/opt/dragoon/dragoon.jar</directory>
<filemode>755</filemode>
<username>dragoon</username>
<groupname>dragoon</groupname>
<sources>
<source>
<location>${basedir}/target/dragoon-${project.version}-jar-with-dependencies.jar</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/opt/dragoon/log4j2.xml</directory>
<filemode>755</filemode>
<username>dragoon</username>
<groupname>dragoon</groupname>
<sources>
<source>
<location>${basedir}/src/build/deb/opt/dragoon/log4j2.xml</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/etc/dragoon</directory>
<configuration>true</configuration>
<filemode>755</filemode>
<username>dragoon</username>
<groupname>dragoon</groupname>
<sources>
<source>
<location>${project.basedir}/src/build/deb/etc/dragoon</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/etc/systemd/system/dragoon.service</directory>
<filemode>644</filemode>
<username>root</username>
<groupname>root</groupname>
<sources>
<source>
<location>${project.basedir}/src/build/deb/etc/systemd/system/dragoon.service</location>
</source>
</sources>
</mapping>
</mappings>
<requires>
<require>java-17-openjdk</require>
<require>ffmpeg-free</require>
</requires>
<preinstallScriptlet>
<script>echo "installing ${project.name} now"</script>
</preinstallScriptlet>
<postinstallScriptlet>
<scriptFile>src/build/scripts/postinstall.sh</scriptFile>
<fileEncoding>utf-8</fileEncoding>
<filter>true</filter>
</postinstallScriptlet>
</configuration>
</plugin>
<plugin> <plugin>
<artifactId>maven-install-plugin</artifactId> <artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version> <version>2.5.2</version>
@ -117,6 +268,5 @@
<version>3.0.0</version> <version>3.0.0</version>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement>
</build> </build>
</project> </project>

1
src/build/changelog.txt Normal file
View File

@ -0,0 +1 @@
# Check https://git.metaunix.net/bitgoblin/dragoon/releases for the current changelog

View File

@ -0,0 +1,9 @@
# 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
interval = 30
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

View File

@ -0,0 +1,11 @@
[Unit]
Description=Dragoon video transcoder service
[Service]
User=dragoon
Group=dragoon
ExecStart=/usr/bin/java -Dlog4j.configurationFile=/opt/dragoon/log4j2.xml -jar '/opt/dragoon/dragoon.jar' -c '/etc/dragoon/config.toml'
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info" name="Dragoon" packages="">
<Appenders>
<File name="DragoonLog" fileName="/opt/dragoon/logs/dragoon.log">
<PatternLayout>
<Pattern>%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Pattern>
</PatternLayout>
</File>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%highlight{%d [%t] %-5level: %msg%n%throwable}" />
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="DragoonLog"/>
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,23 @@
#!/bin/sh
GETENT_USER=$(getent passwd dragoon)
GETENT_GROUP=$(getent group dragoon)
# Create the dragoon user if it doesn't already exist
if [ "$GETENT_USER" = "" ]; then
useradd -r dragoon
else
echo "The 'dragoon' user already exists, skipping creation."
fi
# Create the dragoon group if it doesn't already exist
if [ "$GETENT_GROUP" = "" ]; then
groupadd dragoon
usermod -aG dragoon dragoon
else
echo "The 'dragoon' group already exists, skipping creation."
fi
# Change the directory ownership of /opt and /etc
chown -R dragoon:dragoon /etc/dragoon
chown -R dragoon:dragoon /opt/dragoon

View File

@ -1,5 +1,7 @@
package tech.bitgoblin; package tech.bitgoblin;
import org.apache.commons.cli.ParseException;
import tech.bitgoblin.config.Cmd;
import tech.bitgoblin.config.Config; import tech.bitgoblin.config.Config;
import tech.bitgoblin.transcoder.RunTranscoderTask; import tech.bitgoblin.transcoder.RunTranscoderTask;
import tech.bitgoblin.transcoder.Transcoder; import tech.bitgoblin.transcoder.Transcoder;
@ -12,13 +14,15 @@ import java.util.Timer;
*/ */
public class App { public class App {
private static final String configFile = "~/.config/dragoon.toml";
private static final int msToMinutes = 60 * 1000; private static final int msToMinutes = 60 * 1000;
public static void main(String[] args) { public static void main(String[] args) throws ParseException {
// parse command-line options
Cmd cmd = new Cmd(args);
// read our config file // read our config file
Config c = new Config(configFile); Config c = new Config(cmd.getConfigPath());
// create new Transcoder object and start the service // create new Transcoder object and start the service
Transcoder t = new Transcoder(c); Transcoder t = new Transcoder(c);
Timer timer = new Timer(); Timer timer = new Timer();

View File

@ -4,6 +4,6 @@ import org.apache.logging.log4j.LogManager;
public class Logger { public class Logger {
public static org.apache.logging.log4j.Logger logger = LogManager.getLogger(); public static org.apache.logging.log4j.Logger logger = LogManager.getRootLogger();
} }

View File

@ -0,0 +1,30 @@
package tech.bitgoblin.config;
import org.apache.commons.cli.*;
public class Cmd {
private String configPath = "~/.config/dragoon.toml";
public Cmd(String[] args) throws ParseException {
Options options = new Options();
Option configPath = new Option("c", "configPath", true, "configuration file path (defaults to /etc/dragoon/config.toml)");
configPath.setRequired(false);
options.addOption(configPath);
CommandLineParser parser = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd = parser.parse(options, args);
// set the configPath variable if the option was passed to the program
if (cmd.hasOption("configPath")) {
this.configPath = cmd.getOptionValue("configPath");
}
}
public String getConfigPath() {
return this.configPath;
}
}

View File

@ -1,6 +1,5 @@
package tech.bitgoblin.config; package tech.bitgoblin.config;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;

View File

@ -1,7 +1,5 @@
package tech.bitgoblin.io; package tech.bitgoblin.io;
import tech.bitgoblin.Logger;
import java.io.*; import java.io.*;
public class IOUtils { public class IOUtils {

View File

@ -4,11 +4,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.InterruptedException; import java.lang.InterruptedException;
import java.lang.Process; import java.lang.Process;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Timer;
import tech.bitgoblin.Logger; import tech.bitgoblin.Logger;
import tech.bitgoblin.config.Config; import tech.bitgoblin.config.Config;
@ -67,18 +63,28 @@ public class Transcoder {
String filename = Paths.get(filePath).getFileName().toString(); String filename = Paths.get(filePath).getFileName().toString();
String outputPath = Paths.get(this.repo.getOutputPath(), String.format("%s.mov", filename)).toString(); String outputPath = Paths.get(this.repo.getOutputPath(), String.format("%s.mov", filename)).toString();
String cmd = String.format("%s -i %s -y -f %s -c:v %s -vf %s -profile:v %s -c:a %s %s", // build the custom video parameters string
this.ffmpeg_path, // FFMPEG binary path String videoParameters = String.format("scale=%s,fps=%s,format=%s",
sourceFile.toString(), // input file this.config.getString("transcoder.video_resolution"), // video resolution
this.config.getString("transcoder.video_format"), // video container format this.config.getString("transcoder.video_framerate"), // video frame rate
this.config.getString("transcoder.video_codec"), // video codec this.config.getString("transcoder.video_color") // video color format
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
); );
ProcessBuilder pb = new ProcessBuilder(cmd.split("\\s+")); String cmd = String.format("%s -i INPUT_FILE -y -f %s -c:v %s -vf %s -profile:v %s -c:a %s OUTPUT_FILE",
this.ffmpeg_path, // FFMPEG binary path
this.config.getString("transcoder.video_format"), // video container format
this.config.getString("transcoder.video_codec"), // video codec
videoParameters, // custom video parameters
this.config.getString("transcoder.video_profile"), // video profile
this.config.getString("transcoder.audio_codec") // audio codec
);
String[] cmdArr = cmd.split("\\s+");
cmdArr[2] = sourceFile.toString();
cmdArr[cmdArr.length - 1] = outputPath;
System.out.println(String.join(" ", cmdArr));
ProcessBuilder pb = new ProcessBuilder(cmdArr);
pb.inheritIO(); // use the java processes' input and output streams pb.inheritIO(); // use the java processes' input and output streams
try { try {
Process process = pb.start(); Process process = pb.start();

BIN
src/main/resources/icon.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -0,0 +1,17 @@
package tech.bitgoblin.config;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.apache.commons.cli.ParseException;
public class CmdTest {
@Test
public void shouldDefaultToHome() throws ParseException {
Cmd cmd = new Cmd(new String[]{});
assertTrue(cmd.getConfigPath().equals("~/.config/dragoon.toml"));
}
}

View File

@ -8,7 +8,6 @@ import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
@ -38,6 +37,7 @@ public class IOUtilsTest {
public void fileShouldBeLocked() throws IOException { public void fileShouldBeLocked() throws IOException {
RandomAccessFile raf = new RandomAccessFile(testFile, "rw"); RandomAccessFile raf = new RandomAccessFile(testFile, "rw");
assertTrue(IOUtils.isFileLocked(new File(testFile))); assertTrue(IOUtils.isFileLocked(new File(testFile)));
raf.close();
} }
@Test @Test