Java에서 ffmpeg를 실행 중입니다. 그것을 사용하여 flv 파일을 mp3로 변환합니다.cmd에서 프로세스가 실행되지 않습니다.
아래 코드를 실행하면 ffmpeg가 시작되어 새 파일 (.mp3 파일)이 생성되지만 CPU의 0 %에서 실행됩니다. (netbeans에서) 자바 애플 리케이션을 중지하면 ffmpeg는 열려 있고 Windows 작업 관리자 (CTRL-ALT-DEL) 당 0 %에서 99 %까지 진행됩니다. 또 다른 이상한 일이 벌어지고 있습니다. ffmpeg의 출력이 인쇄되지 않습니다.
스레드가 시작되고 있지만 어떤 이유로 인해 처리를 수행 할 시간이 없습니다.
이 문제를 해결하는 방법에 대한 제안 사항이 있으십니까? 감사.
public class ConverterThread extends Thread {
String fileToConvert;
String fileToCreate;
GetSong getSong;
public ConverterThread(String downloadLocationOnDisk, GetSong getSong) {
this.fileToConvert = downloadLocationOnDisk;
this.getSong = getSong;
}
public void run(){
try {
Thread cur=Thread.currentThread();
cur.setPriority(Thread.MAX_PRIORITY);
String downloadLocationOnDisk = fileToConvert;
if(downloadLocationOnDisk.contains(".flv"))
fileToCreate = downloadLocationOnDisk.replace(".flv", ".mp3");
if(downloadLocationOnDisk.contains(".m4a"))
fileToCreate = downloadLocationOnDisk.replace(".m4a", ".mp3");
String cmdLine = "ffmpeg/bin/ffmpeg -i \"" + fileToConvert + "\" \"" + fileToCreate +"\"";
System.err.println(cmdLine);
// run the Unix "ps -ef" command
// using the Runtime exec method:
Process p = Runtime.getRuntime().exec(cmdLine);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
String s;
// read the output from the command
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
} catch (IOException ex) {
Logger.getLogger(ConverterThread.class.getName()).log(Level.SEVERE, null, ex);
}
나는 당신이 제안한대로 시도했다. 여전히 같은 결과. – FredTheLover
'gedit' 또는'notepad.exe'와 같은 것을 exec 할 수 있습니까? 그것은 어떤 결과를 낳을 것인가? 난 당신의 코드를 시도하고'gedit' 응용 프로그램을 실행했다. 또한 출력도 보았습니다. – gkuzmin