對不起,當我標記ffmpeg,因爲我不能標記MP4Box.But我有prpm與ffmpeg通過javacode也執行。 我在How to execute cmd commands via Java閱讀,但我找不到我的proplem。通過java執行mp4box cmd得到了錯誤
在cmd中,我測試的命令,這是確定:
MP4Box -dash 10000 -dash-profile live -segment-name output- seg -rap -bs-switching no input.mp4
但是當我通過Java代碼執行CMD,我得到錯誤:
Error - only one input file found as argument, please check usage
下面是我的代碼,有什麼錯誤?
package com.uit.reformatvideo;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Logger;
public class ExecuteComandToFormatVideo {
public final static String LINK_MP4BOX = "C:/MP4Box/Tools/MP4Box.exe";
public final static String CREATE_MPD_ECLIPSE = "mp4box -dash 10000 -frag 1000 -rap -bs-switching no";
public final static String CREATE_MPD_IE = "MP4Box -dash 10000 -dash-profile live -segment-name output-seg -rap -bs-switching no";
private static final Logger log = Logger.getLogger(ExecuteComandToFormatVideo.class.getName());
public static void main(String[] args) throws IOException, InterruptedException {
String s = null;
try {
// run the Unix "ps -ef" command
// using the Runtime exec method:
String lsCmd[] = new String [2];
lsCmd[0] = LINK_MP4BOX;
lsCmd[1] = "MP4Box -dash 10000 -dash-profile live -segment-name output-seg -rap -bs-switching no input.mp4";
Process p = Runtime.getRuntime().exec(lsCmd);
p.waitFor();
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
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);
}
System.exit(0);
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
}
}
這裏被放出來:
Here is the standard output of the command:
Here is the standarderror of the command (if any): Error - only one input file found as argument, please check usage
我已經通過批處理文件解決了我的問題。 – Ducthien
由於您找到了解決方案,因此建議您提供答案。 – LordNeckbeard
感謝LordNeckBeard :) – Ducthien