Skip to content

Commit

Permalink
Merge pull request #333 from yermak/development
Browse files Browse the repository at this point in the history
Merging fixes for m4b optimisation and files clean-up
  • Loading branch information
yermak authored Dec 19, 2021
2 parents 7dcb77b + b189321 commit 43c261b
Show file tree
Hide file tree
Showing 36 changed files with 198 additions and 70 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ Main features:
* Instant playback: listen what you are going to encode
* Simple and lightweigh user interface: Convert a book with few clicks

Just download the file from link bellow, no QuickTime or iTunes is required.


If you looking for safe option to install better tested software from trusted source and get automatic incremental updates use <a href="https://store.steampowered.com/app/1529240/AudioBookConverter/">Steam</a>
======

alternatively look at <a href="https://community.chocolatey.org/packages/audiobookconverter">Chocolaty</a>
----
<a href="https://github.com/yermak/AudioBookConverter/releases/latest">Download</a>
=======

or just download <a href="https://github.com/yermak/AudioBookConverter/releases/latest">latest build</a>, no QuickTime or iTunes is required.

You may want to check <a href="https://github.com/yermak/AudioBookConverter/wiki/Installation">Installation Manual</a>
----

Expand Down
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ steps:

- script: |
choco install wget --no-progress
wget -q https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_windows-x64_bin.zip -O openjdk-16.0.2_windows-x64_bin.zip
7z.exe x openjdk-16.0.2_windows-x64_bin.zip
setx JAVA_HOME jdk-16.0.2
wget -q https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_windows-x64_bin.zip -O openjdk-17.0.1_windows-x64_bin.zip
7z.exe x openjdk-17.0.1_windows-x64_bin.zip
setx JAVA_HOME jdk-17.0.1
call refreshenv
call mvn -X clean package -Dexec.skip=true --no-transfer-progress $(MAVEN_OPTS)
displayName: 'Build app without installer'
12 changes: 6 additions & 6 deletions build/linux/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ cd target/image
tar -czf ../release/AudioBookConverter-static-binaries-$APP_VERSION.tar.gz AudioBookConverter
cd ../..

$JAVA_HOME/bin/jpackage --app-version $APP_VERSION --license-file LICENSE --icon AudioBookConverter.png \
-t deb --name AudioBookConverter --vendor Recoupler \
--linux-menu-group AudioBookConverter --linux-shortcut \
--input target/package/audiobookconverter-$APP_VERSION-linux-nodeps-installer/audiobookconverter-$APP_VERSION/app \
--main-jar lib/audiobookconverter-$APP_VERSION.jar --runtime-image target/fx-jre --java-options '--enable-preview'
#$JAVA_HOME/bin/jpackage --app-version $APP_VERSION --license-file LICENSE --icon AudioBookConverter.png \
#-t deb --name AudioBookConverter --vendor Recoupler \
#--linux-menu-group AudioBookConverter --linux-shortcut \
#--input target/package/audiobookconverter-$APP_VERSION-linux-nodeps-installer/audiobookconverter-$APP_VERSION/app \
#--main-jar lib/audiobookconverter-$APP_VERSION.jar --runtime-image target/fx-jre --java-options '--enable-preview'

mv audiobookconverter_$APP_VERSION-1_amd64.deb target/release/
#mv audiobookconverter_$APP_VERSION-1_amd64.deb target/release/
25 changes: 11 additions & 14 deletions build_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ jobs:
tokenSuffix: '}#'

- bash: |
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
sudo apt-get install adoptopenjdk-16-hotspot
sudo apt-get install ffmpeg
sudo apt-get install mp4v2-utils
export JAVA_HOME=/usr/lib/jvm/adoptopenjdk-16-hotspot-amd64
wget -q https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_linux-x64_bin.tar.gz -O openjdk-17.0.1_linux-x64_bin.tar.gz
tar -xzf openjdk-17.0.1_linux-x64_bin.tar.gz
export JAVA_HOME=jdk-17.0.1
export JAVAFX_JMODS=jmods/linux
mvn clean package --no-transfer-progress
Expand All @@ -54,11 +51,11 @@ jobs:
displayName: 'Build deb package'
- bash: |
wget -q https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_osx-x64_bin.tar.gz -O openjdk-16.0.2_osx-x64_bin.tar.gz
tar -xzf openjdk-16.0.2_osx-x64_bin.tar.gz
sudo mv jdk-16.0.2.jdk /Library/Java/JavaVirtualMachines/
rm openjdk-16.0.2_osx-x64_bin.tar.gz
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
wget -q https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_macos-x64_bin.tar.gz -O openjdk-17.0.1_osx-x64_bin.tar.gz
tar -xzf openjdk-17.0.1_osx-x64_bin.tar.gz
sudo mv jdk-17.0.1.jdk /Library/Java/JavaVirtualMachines/
rm openjdk-17.0.1_osx-x64_bin.tar.gz
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home
brew install ffmpeg
brew install mp4v2
export JAVAFX_JMODS=jmods/mac
Expand All @@ -83,9 +80,9 @@ jobs:
ECHO ON
choco install 7zip --no-progress
choco install wget --no-progress
wget -q https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_windows-x64_bin.zip -O openjdk-16.0.2_windows-x64_bin.zip
7z.exe x openjdk-16.0.2_windows-x64_bin.zip
setx JAVA_HOME jdk-16.0.2
wget -q https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_windows-x64_bin.zip -O openjdk-17.0.1_windows-x64_bin.zip
7z.exe x openjdk-17.0.1_windows-x64_bin.zip
setx JAVA_HOME jdk-17.0.1
call refreshenv
SET JAVAFX_JMODS=jmods/windows
Expand Down
4 changes: 4 additions & 0 deletions external/x64/choco/path.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ffmpeg=ffmpeg.exe
ffprobe=ffprobe.exe
mp4art=mp4art.exe
mp4info=mp4info.exe
Binary file modified jmods/linux/javafx.base.jmod
Binary file not shown.
Binary file modified jmods/linux/javafx.controls.jmod
Binary file not shown.
Binary file modified jmods/linux/javafx.fxml.jmod
Binary file not shown.
Binary file modified jmods/linux/javafx.graphics.jmod
Binary file not shown.
Binary file modified jmods/linux/javafx.media.jmod
Binary file not shown.
Binary file modified jmods/linux/javafx.swing.jmod
Binary file not shown.
Binary file modified jmods/linux/javafx.web.jmod
Binary file not shown.
Binary file modified jmods/mac/javafx.base.jmod
Binary file not shown.
Binary file modified jmods/mac/javafx.controls.jmod
Binary file not shown.
Binary file modified jmods/mac/javafx.fxml.jmod
Binary file not shown.
Binary file modified jmods/mac/javafx.graphics.jmod
Binary file not shown.
Binary file modified jmods/mac/javafx.media.jmod
Binary file not shown.
Binary file modified jmods/mac/javafx.swing.jmod
Binary file not shown.
Binary file modified jmods/mac/javafx.web.jmod
Binary file not shown.
Binary file modified jmods/windows/javafx.base.jmod
Binary file not shown.
Binary file modified jmods/windows/javafx.controls.jmod
Binary file not shown.
Binary file modified jmods/windows/javafx.fxml.jmod
Binary file not shown.
Binary file modified jmods/windows/javafx.graphics.jmod
Binary file not shown.
Binary file modified jmods/windows/javafx.media.jmod
Binary file not shown.
Binary file modified jmods/windows/javafx.swing.jmod
Binary file not shown.
Binary file modified jmods/windows/javafx.web.jmod
Binary file not shown.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<version>#{APP_VERSION}#</version>

<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<compiler.generate.no.warnings>off</compiler.generate.no.warnings>
<compiler.max.memory>700m</compiler.max.memory>
<compiler.debug>on</compiler.debug>
<compiler.args.main>--enable-preview</compiler.args.main>
<javafx.version>16</javafx.version>
<javafx.version>17.0.1</javafx.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down
27 changes: 12 additions & 15 deletions release-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trigger:

variables:
# APP_VERSION: '5.4.$(Build.BuildNumber)'
VERSION: 5.5
VERSION: 5.6
BUILD_COUNTER: $[counter(variables['VERSION'], 0)]
APP_VERSION: '$(VERSION).$(BUILD_COUNTER)'

Expand Down Expand Up @@ -44,10 +44,9 @@ jobs:
tokenSuffix: '}#'

- bash: |
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
sudo apt-get install adoptopenjdk-16-hotspot
export JAVA_HOME=/usr/lib/jvm/adoptopenjdk-16-hotspot-amd64
wget -q https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_linux-x64_bin.tar.gz -O openjdk-17.0.1_linux-x64_bin.tar.gz
tar -xzf openjdk-17.0.1_linux-x64_bin.tar.gz
export JAVA_HOME=jdk-17.0.1
export JAVAFX_JMODS=jmods/linux
mvn clean package --no-transfer-progress
Expand All @@ -57,13 +56,11 @@ jobs:
displayName: 'Build deb package'
- bash: |
wget -q https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_osx-x64_bin.tar.gz -O openjdk-16.0.2_osx-x64_bin.tar.gz
tar -xzf openjdk-16.0.2_osx-x64_bin.tar.gz
sudo mv jdk-16.0.2.jdk /Library/Java/JavaVirtualMachines/
rm openjdk-16.0.2_osx-x64_bin.tar.gz
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
brew install ffmpeg
brew install mp4v2
wget -q https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_macos-x64_bin.tar.gz -O openjdk-17.0.1_osx-x64_bin.tar.gz
tar -xzf openjdk-17.0.1_osx-x64_bin.tar.gz
sudo mv jdk-17.0.1.jdk /Library/Java/JavaVirtualMachines/
rm openjdk-17.0.1_osx-x64_bin.tar.gz
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home
export JAVAFX_JMODS=jmods/mac
mvn clean package --no-transfer-progress
Expand All @@ -85,9 +82,9 @@ jobs:
ECHO ON
choco install 7zip --no-progress
choco install wget --no-progress
wget -q https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_windows-x64_bin.zip -O openjdk-16.0.2_windows-x64_bin.zip
7z.exe x openjdk-16.0.2_windows-x64_bin.zip
setx JAVA_HOME jdk-16.0.2
wget -q https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_windows-x64_bin.zip -O openjdk-17.0.1_windows-x64_bin.zip
7z.exe x openjdk-17.0.1_windows-x64_bin.zip
setx JAVA_HOME jdk-11.0.1
call refreshenv
SET JAVAFX_JMODS=jmods/windows
Expand Down
10 changes: 10 additions & 0 deletions src/main/deploy/assembly/windows-nodeps-installer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@
<fileSet>
<includes>
<include>README*</include>
<include>*.txt</include>
<include>*.ico</include>
</includes>
<outputDirectory>app</outputDirectory>
</fileSet>
<fileSet>
<directory>external/x64/choco</directory>
<outputDirectory>app</outputDirectory>
<includes>
<include>path.properties</include>
</includes>
</fileSet>
</fileSets>


<dependencySets>
<dependencySet>
<includes>
Expand Down
27 changes: 7 additions & 20 deletions src/main/java/uk/yermak/audiobookconverter/ConversionJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import uk.yermak.audiobookconverter.fx.ConverterApplication;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.invoke.MethodHandles;
Expand All @@ -32,13 +31,15 @@ public class ConversionJob implements Runnable {
private final Map<String, ProgressCallback> progressCallbacks;
private final String outputDestination;
private final SimpleObjectProperty<ProgressStatus> status = new SimpleObjectProperty<>(this, "status", READY);
long jobId;


public ConversionJob(ConversionGroup conversionGroup, Convertable convertable, Map<String, ProgressCallback> progressCallbacks, String outputDestination) {
this.conversionGroup = conversionGroup;
this.convertable = convertable;
this.progressCallbacks = progressCallbacks;
this.outputDestination = outputDestination;
jobId = outputDestination.hashCode() + System.currentTimeMillis();

addStatusChangeListener((observable, oldValue, newValue) -> {
if (FINISHED.equals(newValue)) {
Expand All @@ -52,22 +53,17 @@ public void run() {
status.set(IN_PROGRESS);

List<Future<String>> futures = new ArrayList<>();
long jobId = outputDestination.hashCode() + System.currentTimeMillis();

String tempFile = Utils.getTmp(jobId, outputDestination.hashCode(), conversionGroup.getWorkfileExtension());

File fileListFile = null;
File metaFile = null;
try {
// conversion.getOutputParameters().updateAuto(conversion.getMedia());

fileListFile = prepareFiles(jobId);


List<MediaInfo> prioritizedMedia = prioritiseMedia();

for (MediaInfo mediaInfo : prioritizedMedia) {
String tempOutput = Utils.getTmp(jobId, mediaInfo.hashCode() + mediaInfo.getDuration(), conversionGroup.getWorkfileExtension());
String tempOutput = Utils.getTmp(jobId, mediaInfo.getFileName().hashCode(), conversionGroup.getWorkfileExtension());
ProgressCallback callback = progressCallbacks.get(mediaInfo.getFileName() + "-" + mediaInfo.getDuration());
Future<String> converterFuture = executorService.submit(new FFMpegNativeConverter(this, mediaInfo, tempOutput, callback));
futures.add(converterFuture);
Expand All @@ -80,7 +76,7 @@ public void run() {
}
if (status.get().isOver()) return;

FFMpegConcatenator concatenator = new FFMpegConcatenator(this, tempFile, new MetadataBuilder(jobId, conversionGroup, convertable), fileListFile.getAbsolutePath(), progressCallbacks.get("output"));
FFMpegConcatenator concatenator = new FFMpegConcatenator(this, tempFile, new MetadataBuilder(jobId, conversionGroup, convertable), convertable.getMedia(), progressCallbacks.get("output"));
concatenator.concat();

if (status.get().isOver()) return;
Expand All @@ -91,9 +87,7 @@ public void run() {
}

if (status.get().isOver()) return;
File destFile = new File(outputDestination);
if (destFile.exists()) FileUtils.deleteQuietly(destFile);
FileUtils.moveFile(new File(tempFile), destFile);
new FFMpegOptimizer(this, tempFile, outputDestination, progressCallbacks.get("output")).moveResultingFile();
finished();
} catch (Exception e) {
logger.error("Error during parallel conversion", e);
Expand All @@ -102,11 +96,12 @@ public void run() {
e.printStackTrace(new PrintWriter(sw));
error(e.getMessage() + "; " + sw.getBuffer().toString());
} finally {
/*
for (MediaInfo mediaInfo : convertable.getMedia()) {
FileUtils.deleteQuietly(new File(Utils.getTmp(jobId, mediaInfo.hashCode() + mediaInfo.getDuration(), conversionGroup.getWorkfileExtension())));
}
*/
FileUtils.deleteQuietly(metaFile);
FileUtils.deleteQuietly(fileListFile);
}
}

Expand All @@ -115,14 +110,6 @@ private List<MediaInfo> prioritiseMedia() {
}


protected File prepareFiles(long jobId) throws IOException {
File fileListFile = new File(System.getProperty("java.io.tmpdir"), "filelist." + jobId + ".txt");
List<String> outFiles = convertable.getMedia().stream().map(mediaInfo -> "file '" + Utils.getTmp(jobId, mediaInfo.hashCode() + mediaInfo.getDuration(), conversionGroup.getWorkfileExtension()) + "'").collect(Collectors.toList());
FileUtils.writeLines(fileListFile, "UTF-8", outFiles);
return fileListFile;
}


public void addStatusChangeListener(ChangeListener<ProgressStatus> listener) {
status.addListener(listener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public ArtWork call() throws Exception {
"-y",
poster);
process = pictureProcessBuilder.start();
new File(poster).deleteOnExit();

ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamCopier.copy(process.getInputStream(), out);
Expand Down
23 changes: 19 additions & 4 deletions src/main/java/uk/yermak/audiobookconverter/FFMpegConcatenator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.bramp.ffmpeg.progress.ProgressParser;
import net.bramp.ffmpeg.progress.TcpProgressParser;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -10,8 +11,10 @@
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
* Created by Yermak on 29-Dec-17.
Expand All @@ -23,21 +26,31 @@ public class FFMpegConcatenator {
private final String outputFileName;

private final MetadataBuilder metadataBuilder;
private final String fileListFileName;
private List<MediaInfo> media;
private final ProgressCallback callback;
private ProgressParser progressParser;
private List<String> tmpFiles = new ArrayList<>();
private String fileListFileName;


public FFMpegConcatenator(ConversionJob conversionJob, String outputFileName, MetadataBuilder metadataBuilder, String fileListFileName, ProgressCallback callback) {
public FFMpegConcatenator(ConversionJob conversionJob, String outputFileName, MetadataBuilder metadataBuilder, List<MediaInfo> media, ProgressCallback callback) {
this.conversionJob = conversionJob;
this.outputFileName = outputFileName;
this.metadataBuilder = metadataBuilder;
this.fileListFileName = fileListFileName;
this.media = media;
this.callback = callback;
}

protected static File prepareFiles(long jobId, List<MediaInfo> media, String workfileExtension) throws IOException {
File fileListFile = new File(System.getProperty("java.io.tmpdir"), "filelist." + jobId + ".txt");
List<String> outFiles = media.stream().map(mediaInfo -> "file '" + Utils.getTmp(jobId, mediaInfo.getFileName().hashCode(), workfileExtension) + "'").collect(Collectors.toList());
FileUtils.writeLines(fileListFile, "UTF-8", outFiles);
return fileListFile;
}

public void concat() throws IOException, InterruptedException {
if (conversionJob.getStatus().isOver()) return;
fileListFileName = prepareFiles(conversionJob.jobId, media, conversionJob.getConversionGroup().getWorkfileExtension()).getAbsolutePath();

while (ProgressStatus.PAUSED.equals(conversionJob.getStatus())) Thread.sleep(1000);
callback.reset();
try {
Expand Down Expand Up @@ -83,6 +96,8 @@ public void concat() throws IOException, InterruptedException {
} finally {
Utils.closeSilently(process);
Utils.closeSilently(progressParser);
media.forEach(mediaInfo -> FileUtils.deleteQuietly(new File(Utils.getTmp(conversionJob.jobId, mediaInfo.getFileName().hashCode(), conversionJob.getConversionGroup().getWorkfileExtension()))));
FileUtils.deleteQuietly(new File(fileListFileName));
}
}
}
Loading

0 comments on commit 43c261b

Please sign in to comment.