I am running SoX using using a ProcessBuilder in java that trims WAV files into 30 second long WAV files.
SoX is running because I can get the first 30 seconds of the file successfully trimmed and saved as a new file but it stops there however, it's still running.
This is the code for the command generation:
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 ());
}
This is the code for the process creation:
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;
}