Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 6 initial release #362

Merged
merged 47 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
42cec03
Mac OS Build
yermak Oct 29, 2021
d041e26
Merge branch 'issues/312_m4b_optimisatin' into macos
yermak Dec 13, 2021
1e8adde
Merge branch 'feature/318_force_reencoding' into macos
yermak Dec 13, 2021
4148a0c
moved os dependand tools and Dev plugs into Environment
yermak Dec 13, 2021
4608538
Merge branch 'development' into macos
yermak Dec 20, 2021
d7a7259
merge fixes
yermak Dec 20, 2021
e3172b7
fixed macos/windows environment issues
yermak Dec 20, 2021
eef4f07
fixed macos/windows environment issues
yermak Dec 20, 2021
bd62c63
fixed macos/windows environment issues
yermak Dec 20, 2021
1b0ba8f
Merge pull request #341 from yermak/macos
yermak Dec 20, 2021
6e1fd64
fixed version hack
yermak Dec 20, 2021
fd5d7bc
fixed version hack
yermak Dec 20, 2021
fa6300c
clean-up
yermak Dec 20, 2021
7177de8
clean-up
yermak Dec 20, 2021
344c18a
Merge pull request #342 from yermak/clean-up
yermak Dec 20, 2021
fa13b0f
fixed potential image name clash in temp files
yermak Dec 22, 2021
f85a14d
Merge pull request #344 from yermak/issue/343_artwork_conflict
yermak Dec 22, 2021
9dc738d
Fixed random io bug on iOS while searching artwork on samba network d…
yermak Dec 23, 2021
3e003a5
Fixed combining Parts
yermak Dec 23, 2021
f03f61c
Fixed splitting chapters
yermak Dec 23, 2021
843e697
Merge pull request #346 from yermak/issue/345_split_combine
yermak Dec 23, 2021
16af7b6
added Xodus database instead of property file, Moved genres to database
yermak Dec 24, 2021
2b9b105
moved presets to database
yermak Dec 24, 2021
5e63bf1
propperties moved to database
yermak Dec 24, 2021
62ec7e2
renamed properties into settings
yermak Dec 24, 2021
e6f2923
fixed NPE in loading properties from settings db
yermak Dec 25, 2021
6249091
adding lazy reencoding option and fixing optimisation error
yermak Dec 27, 2021
49d81b2
adding lazy reencoding option and fixing optimisation error
yermak Dec 27, 2021
7e7ad8b
Merge pull request #348
yermak Dec 27, 2021
b705e98
Merge pull request #350 from yermak/features/206_avoid_reencoding
yermak Dec 27, 2021
24572e2
adding progress for artwork and optimisation, fixed force reencoding
yermak Dec 28, 2021
0923da5
Merge pull request #351 from yermak/features/332_progress_for_art_wor…
yermak Dec 28, 2021
25be3d3
fixed preset saving behaviour
yermak Dec 28, 2021
5d83963
fixed preset saving behaviour
yermak Dec 28, 2021
955fb44
fixed preset saving behaviour
yermak Dec 28, 2021
622a381
fixed preset saving behaviour
yermak Dec 28, 2021
97922cf
Merge pull request #354 from yermak/issue/347_app_settings
yermak Dec 28, 2021
c59aea2
fixed #269
yermak Dec 28, 2021
61a88d7
Merge pull request #355 from yermak/issues/269_subtracks_single_file
yermak Dec 28, 2021
82c62bf
packaging jdk for xodus
yermak Dec 28, 2021
9c30da0
Merge pull request #356
yermak Dec 28, 2021
3fb7ad5
division by zero fix
yermak Dec 28, 2021
3e04887
Merge pull request #357
yermak Dec 28, 2021
db10c17
fixed optimsation issue with jpg art added as binary data
yermak Dec 29, 2021
bac8f37
Merge pull request #360
yermak Dec 29, 2021
cd3f709
version bump
yermak Dec 29, 2021
0208959
Merge pull request #361
yermak Dec 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/main/java/uk/yermak/audiobookconverter/AppSetting.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,27 @@ public class AppSetting {
public static final String GENRE_TITLE = "title";
public static final String GENRE_CREATED = "created";
public static final String SETTINGS = "Settings";
public static final String PRESET_SPEED = "speed";
public static final String PRESET_FORCE = "force";
public static final String PRESET_SPLIT_CHAPTERS = "split_chapters";
private static Map<String, String> cache = new ConcurrentHashMap<>();

public static final String VERSION = "version";

static {
try (jetbrains.exodus.env.Environment env = Environments.newInstance(APP_DIR.getPath())) {
env.executeInTransaction(txn -> {
final Store store = env.openStore(SETTINGS, StoreConfig.WITHOUT_DUPLICATES, txn);
store.put(txn, StringBinding.stringToEntry(VERSION), StringBinding.stringToEntry(Version.getVersionString()));
});
}

}

public static synchronized String getProperty(String key) {
String result = cache.get(key);
if (result != null) return result;
logger.debug("Settings cache is missed for property: " + key);
try (jetbrains.exodus.env.Environment env = Environments.newInstance(APP_DIR.getPath())) {
result = env.computeInReadonlyTransaction(txn -> {
final Store store = env.openStore(SETTINGS, StoreConfig.WITHOUT_DUPLICATES, txn);
Expand All @@ -52,13 +67,16 @@ public static synchronized String getProperty(String key) {
return null;
}
});
cache.put(key, result);
if (result != null) {
cache.put(key, result);
}
}
return result;
}

public static synchronized void setProperty(String key, String value) {
cache.put(key, value);
logger.debug("Updating settings cache and database with key: [" + key + "] and value: [" + value + "]");
try (jetbrains.exodus.env.Environment env = Environments.newInstance(APP_DIR.getPath())) {
env.executeInTransaction(txn -> {
final Store store = env.openStore(SETTINGS, StoreConfig.WITHOUT_DUPLICATES, txn);
Expand Down Expand Up @@ -128,7 +146,10 @@ private static Preset bindPreset(Entity entity) {
Integer cutoff = (Integer) entity.getProperty(PRESET_CUTOFF);
Boolean cbr = (Boolean) entity.getProperty(PRESET_CBR);
Integer quality = (Integer) entity.getProperty(PRESET_QUALITY);
Preset preset = new Preset(name, new OutputParameters(Format.instance(format), bitrate, frequency, channels, cutoff, cbr, quality));
Double speed = (Double) entity.getProperty(PRESET_SPEED);
OutputParameters.Force force = OutputParameters.Force.valueOf((String) entity.getProperty(PRESET_FORCE));
Boolean splitChapters = (Boolean) entity.getProperty(PRESET_SPLIT_CHAPTERS);
Preset preset = new Preset(name, new OutputParameters(Format.instance(format), bitrate, frequency, channels, cutoff, cbr, quality, speed, force, splitChapters));
return preset;
}

Expand All @@ -143,13 +164,16 @@ public static synchronized void savePreset(Preset preset) {
entity = entities.getFirst();
}
entity.setProperty(PRESET_NAME, preset.getName());
entity.setProperty(PRESET_FORMAT, preset.getFormat().format);
entity.setProperty(PRESET_FORMAT, preset.getFormat().extension);
entity.setProperty(PRESET_BITRATE, preset.getBitRate());
entity.setProperty(PRESET_FREQUENCY, preset.getFrequency());
entity.setProperty(PRESET_CHANNELS, preset.getChannels());
entity.setProperty(PRESET_CUTOFF, preset.getCutoff());
entity.setProperty(PRESET_CBR, preset.isCbr());
entity.setProperty(PRESET_QUALITY, preset.getVbrQuality());
entity.setProperty(PRESET_SPEED, preset.getSpeed());
entity.setProperty(PRESET_FORCE, preset.getForce().toString());
entity.setProperty(PRESET_SPLIT_CHAPTERS, preset.isSplitChapters());
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ public void launch(ListView<ProgressComponent> progressQueue, ProgressComponent
// String extension = FilenameUtils.getExtension(outputDestination);
this.getOutputParameters().setupFormat(format);


if (this.getOutputParameters().isSplitChapters()) {
List<Chapter> chapters = parts.stream().flatMap(p -> p.getChapters().stream()).collect(Collectors.toList());
List<Chapter> chapters = parts.stream().flatMap(p -> p.getChapters().stream()).toList();
logger.debug("Found {} chapters in the book", chapters.size());
for (int i = 0; i < chapters.size(); i++) {
Chapter chapter = chapters.get(i);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/uk/yermak/audiobookconverter/Format.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public List<String> getReencodingOptions(MediaInfo mediaInfo, String progressUri
options.add("-t");
options.add(toFFMpegTime(mediaInfo.getDuration()));
}
if (outputParameters.getCutoff() != null) {
if (outputParameters.getCutoff() != 0) {
options.add("-cutoff");
options.add(Integer.toString(outputParameters.getCutoff()));
}
Expand Down Expand Up @@ -236,7 +236,7 @@ public List<String> getReencodingOptions(MediaInfo mediaInfo, String progressUri
options.add("-t");
options.add(toFFMpegTime(mediaInfo.getDuration()));
}
if (outputParameters.getCutoff() != null) {
if (outputParameters.getCutoff() != 0) {
options.add("-cutoff");
options.add(Integer.toString(outputParameters.getCutoff()));
}
Expand Down
39 changes: 22 additions & 17 deletions src/main/java/uk/yermak/audiobookconverter/OutputParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,42 @@ public class OutputParameters {
protected Integer vbrQuality = format.defaultVbrQuality();
protected boolean cbr = format.defaultCBR();
protected Integer cutoff = format.defaultCutoff();
protected transient SimpleObjectProperty<Double> speed = new SimpleObjectProperty(1.0);
protected transient SimpleObjectProperty<Double> speed = new SimpleObjectProperty<>(format.defaultSpeed());

public enum Force {Auto, Always, Avoid}

;

protected Force force = Force.Auto;

private boolean splitChapters = false;


public OutputParameters(OutputParameters parameters) {
this.bitRate = parameters.getBitRate();
this.frequency = parameters.getFrequency();
this.channels = parameters.getChannels();
this.vbrQuality = parameters.getVbrQuality();
this.cbr = parameters.isCbr();
this.cutoff = parameters.getCutoff();
this.format = parameters.getFormat();
this.splitChapters = parameters.isSplitChapters();
this.speed = new SimpleObjectProperty<>(parameters.getSpeed());
this.force = parameters.force;
}

OutputParameters() {
}

OutputParameters(Format format, int bitRate, int frequency, int channels, int cutoff, boolean cbr, int quality) {
OutputParameters(Format format, int bitRate, int frequency, int channels, int cutoff, boolean cbr, int quality, double speed, Force force, boolean splitChapters) {
this.format = format;
this.bitRate = bitRate;
this.frequency = frequency;
this.channels = channels;
this.vbrQuality = quality;
this.cbr = cbr;
this.cutoff = cutoff;
this.speed.set(speed);
this.force = force;
this.splitChapters = splitChapters;
}

public OutputParameters(OutputParameters parameters) {
this(parameters. getFormat(),
parameters.getBitRate(),
parameters.getFrequency(),
parameters.getChannels(),
parameters.getCutoff(), parameters.isCbr(),
parameters.getVbrQuality(),
parameters.getSpeed(),
parameters.getForce(),
parameters.isSplitChapters()
);
}


Expand Down Expand Up @@ -157,5 +158,9 @@ protected void initSpeed() {
public void setForce(Force force) {
this.force = force;
}

public Force getForce() {
return force;
}
}

76 changes: 9 additions & 67 deletions src/main/java/uk/yermak/audiobookconverter/Preset.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public String toString() {


static List<Preset> defaultValues = List.of(
new Preset("ipod nano", new OutputParameters(Format.M4B, 64, 44100, 1, 10000, false, 2)),
new Preset("ipod classic", new OutputParameters(Format.M4B, 96, 44100, 2, 12000, true, 3)),
new Preset("iphone", new OutputParameters(Format.M4B, 128, 44100, 2, 12000, true, 4)),
new Preset("android 5+", new OutputParameters(Format.OGG, 64, 44100, 2, 12000, false, 3)),
new Preset("android old", new OutputParameters(Format.M4B, 96, 44100, 2, 10000, true, 3)),
new Preset("legacy", new OutputParameters(Format.MP3, 128, 44100, 2, 12000, true, 3))
new Preset("ipod nano", new OutputParameters(Format.M4B, 64, 44100, 1, 10000, false, 2, 1.0, Force.Auto, false)),
new Preset("ipod classic", new OutputParameters(Format.M4B, 96, 44100, 2, 12000, true, 3, 1.0, Force.Auto, false)),
new Preset("iphone", new OutputParameters(Format.M4B, 128, 44100, 2, 12000, true, 4, 1.0, Force.Auto, false)),
new Preset("android 5+", new OutputParameters(Format.OGG, 64, 44100, 2, 12000, false, 3, 1.0, Force.Auto, false)),
new Preset("android old", new OutputParameters(Format.M4B, 96, 44100, 2, 10000, true, 3, 1.0, Force.Auto, false)),
new Preset("legacy", new OutputParameters(Format.MP3, 128, 44100, 2, 12000, true, 3, 1.0, Force.Auto, true))
);

public static final Preset DEFAULT_OUTPUT_PARAMETERS = new Preset(Preset.DEFAULT);
Expand All @@ -37,18 +37,10 @@ public static List<Preset> loadPresets() {

}

// private final OutputParameters save;

Preset(String name, OutputParameters preset) {
public Preset(String name, OutputParameters preset) {
super(preset.getFormat(), preset.getBitRate(), preset.getFrequency(), preset.getChannels(), preset.getCutoff(), preset.isCbr(), preset.getVbrQuality(),
preset.getSpeed(), preset.getForce(), preset.isSplitChapters());
this.name = name;
this.bitRate = preset.getBitRate();
this.frequency = preset.getFrequency();
this.channels = preset.getChannels();
this.vbrQuality = preset.getVbrQuality();
this.cbr = preset.isCbr();
this.cutoff = preset.getCutoff();
this.format = preset.getFormat();
// savePreset();
}


Expand All @@ -67,65 +59,15 @@ public static Preset instance(String presetName) {
return new Preset(presetName, new OutputParameters());
}

private void savePreset() {
AppSetting.savePreset(this);
}


@Override
public void setupFormat(Format format) {
super.setupFormat(format);
savePreset();
}


@Override
public void setBitRate(Integer bitRate) {
super.setBitRate(bitRate);
savePreset();
}

@Override
public void setFrequency(Integer frequency) {
super.setFrequency(frequency);
savePreset();
}


@Override
public void setChannels(Integer channels) {
super.setChannels(channels);
savePreset();
}

@Override
public void setVbrQuality(Integer vbrQuality) {
super.setVbrQuality(vbrQuality);
savePreset();
}

@Override
public void setCbr(Boolean cbr) {
super.setCbr(cbr);
savePreset();
}

@Override
public void updateAuto(List<MediaInfo> media) {
if (!defaultValues.contains(this)) {
super.updateAuto(media);
savePreset();
} else {
//Ignoring auto-update and save for all other preset
}
}

@Override
public void setCutoff(Integer cutoff) {
super.setCutoff(cutoff);
savePreset();
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ public void addSpeedChangeListener(ChangeListener<Double> changeListener) {
outputParameters.get().getSpeedObservable().addListener(changeListener);
}

public void setSpeed(Double speed) {
this.outputParameters.get().setSpeed(speed);
}

public void setBook(Book book) {
this.book.set(book);
}
Expand Down
Loading