I am unable to convert my mp3s to wavs for easier data manipulation using Java. I can open a command prompt and copy the exact string stored in s when I debug and this will properly create the wav file. The code is below. I was able to use ffmpeg by building strings this way to split up a few mp3s into separate tracks based on a tracklist. I reinstalled Windows 10, so I'm assuming it has something to do with that. Is there a setting I have to change? Why would it run in the command prompt, but not with Java?
package mp3towav;
import java.io.File;
import java.io.IOException;
public class Mp3towav {
// mp3 folder
public static final String MP3FOLDER = "C:\\Users\\Al\\Documents\\Sounds\\PokemonOST\\YellowOST\\MP3";
public static void main(String[] args) throws IOException {
// Gets the mp3 files and converts them to wav
File mp3folder = new File(MP3FOLDER);
String[] mp3s = mp3folder.list();
File f;
String s;
for(int i = 0; i < mp3s.length; i++) {
f = new File(mp3s[i]);
s = ("ffmpeg -i " + MP3FOLDER + "\\" + f.getName() + " " + (MP3FOLDER + "\\" + f.getName()).replaceAll("MP3", "WAV").replaceAll("mp3", "wav"));
Runtime.getRuntime().exec(s);
System.out.println("test");
}
}
}
Edit:
So I never got Java to use PATH, but added in the absolute path to the ffmpeg executable in Java.