JavaのProcessBuilderを使用してSoXを実行しており、WAVファイルを30秒間のWAVファイルにトリムします。SoXがProcessBuilderを使用して実行速度が遅い
ファイルの最初の30秒が正常にトリムされ、新しいファイルとして保存されるためSoXが実行されていますが、まだ停止していますが、まだ実行中です。
これは、コマンドを生成するためのコードです:
command.add (soxCommand);
if (SoxWrapper.getMetadata (srcFile, MetadataField.SAMPLE_RATE) != 16000) {
command.add ("-V3");
command.add ("-G");
command.add (FilenameUtils.normalize (srcFile.getAbsolutePath()));
command.add ("-b 16");
command.add (FilenameUtils.normalize (destFile.getAbsolutePath()));
command.add ("channels");
command.add ("1");
command.add ("rate");
command.add ("16000");
command.add ("trim");
command.add (startTime.toString());
command.add ('=' + endTime.toString());
} else {
command.add ("-V3");
command.add (FilenameUtils.normalize (srcFile.getAbsolutePath()));
command.add ("-b 16");
command.add (FilenameUtils.normalize (destFile.getAbsolutePath()));
command.add ("trim");
command.add (startTime.toString());
command.add ('=' + endTime.toString());
}
これは、プロセスを作成するためのコードです:
private static Process createProcess (List<String> command) {
ProcessBuilder soxProcessBuilder = new ProcessBuilder (command);
soxProcessBuilder.redirectErrorStream (true);
Process soxProcess = null;
try {
soxProcess = soxProcessBuilder.start();
int soxreturn = soxProcess.waitFor();
soxLogger.info ("SoX returned: " + soxreturn);
} catch (IOException t) {
logger.error ("SoX Process failed", t);
} catch (InterruptedException e) {
logger.error ("Failed to wait for SoX to finish", e);
}
return soxProcess;
}