Improved export system

This commit is contained in:
2018-09-11 23:12:36 +01:00
parent 04e4447b39
commit 3f42a13afd
2 changed files with 20 additions and 9 deletions

View File

@@ -100,11 +100,6 @@ class FFMPEGExecutor {
cmd[i + 1] = (String) args.get(i); cmd[i + 1] = (String) args.get(i);
} }
for (int i = 0; i < argsSize+1; i++) {
System.err.print(cmd[i] + " ");
}
System.err.println();
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
ffmpeg = runtime.exec(cmd); ffmpeg = runtime.exec(cmd);
ffmpegKiller = new ProcessKiller(ffmpeg); ffmpegKiller = new ProcessKiller(ffmpeg);

View File

@@ -1172,13 +1172,11 @@ public class AudiobookRecorder extends JFrame {
int fullLength = 0; int fullLength = 0;
Chapter c = o.nextElement(); Chapter c = o.nextElement();
if (c.getChildCount() == 0) continue;
String name = c.getName(); String name = c.getName();
File exportFile = new File(export, name + ".wax"); File exportFile = new File(export, name + ".wax");
File wavFile = new File(export, name + ".wav"); File wavFile = new File(export, name + ".wav");
File mp3File = new File(export, name + "-untagged.mp3");
File taggedFile = new File(export, name + ".mp3");
FileOutputStream fos = new FileOutputStream(exportFile); FileOutputStream fos = new FileOutputStream(exportFile);
@@ -1205,11 +1203,29 @@ public class AudiobookRecorder extends JFrame {
FileInputStream fis = new FileInputStream(exportFile); FileInputStream fis = new FileInputStream(exportFile);
AudioInputStream ais = new AudioInputStream(fis, format, fullLength); AudioInputStream ais = new AudioInputStream(fis, format, fullLength);
AudioSystem.write(ais, AudioFileFormat.Type.WAVE, wavFile); fos = new FileOutputStream(wavFile);
AudioSystem.write(ais, AudioFileFormat.Type.WAVE, fos);
fos.flush();
fos.close();
fis.close(); fis.close();
exportFile.delete(); exportFile.delete();
}
for (Enumeration<Chapter> o = book.children(); o.hasMoreElements();) {
Chapter c = o.nextElement();
if (c.getChildCount() == 0) continue;
String name = c.getName();
File wavFile = new File(export, name + ".wav");
File mp3File = new File(export, name + "-untagged.mp3");
File taggedFile = new File(export, name + ".mp3");
System.err.println(attributes);
encoder.encode(wavFile, mp3File, attributes); encoder.encode(wavFile, mp3File, attributes);
Mp3File id3 = new Mp3File(mp3File); Mp3File id3 = new Mp3File(mp3File);
ID3v2 tags = new ID3v24Tag(); ID3v2 tags = new ID3v24Tag();