我在Java Web服務下面的代碼:FFMPEG在Java中的問題
public boolean makeFile(String fileName, String audio)
{
if (makeUserFolder())
{
File file = new File(getUserFolderPath() + fileName + amr);
FileOutputStream fileOutputStream = null;
try
{
file.createNewFile();
fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(Base64.decode(audio));
return true;
}
catch(FileNotFoundException ex)
{
return false;
}
catch(IOException ex)
{
return false;
}
finally{
try {
fileOutputStream.close();
convertFile(fileName);
} catch (IOException ex) {
Logger.getLogger(FileUtils.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
else
return false;
}
public boolean convertFile(String fileName)
{
Process ffmpeg;
String filePath = this.userFolderPath + fileName;
try {
ProcessBuilder pb = new ProcessBuilder("ffmpeg","-i",filePath + amr,filePath + mp3);
pb.redirectErrorStream();
ffmpeg = pb.start();
} catch (IOException ex) {
return false;
}
return true;
}
它用來工作,現在它根本不會執行出於某種原因ffmpeg的轉換。我認爲這是我的文件的問題,但從終端運行命令後沒有錯誤拋出或任何東西,認爲這可能是權限問題,但所有的權限已被授予我保存文件的文件夾。我注意到輸入的BufferedReader在運行這個過程後被設置爲null,任何想法發生了什麼?
謝謝,目前我回家了,所以我明天就得測試這個代碼。事情是你上面看到的代碼上週工作,今天當我去做另一個測試,因爲我做了一些改變(不是在這部分代碼)它失敗了,不會轉換音頻文件,認爲這是一個權限問題,但從終端執行命令工作。我會告訴你結果 – 8vius 2011-02-18 02:00:59