извините, когда я помечаю ffmpeg, потому что не могу пометить MP4Box. Но у меня есть proplem с exct с ffmpeg через javacode. Я читал в How to execute cmd commands via Java, но я не могу найти свой проплм.Execute mp4box cmd через java получил ошибку
Я протестированные команды в ЦМД, это было нормально:
MP4Box -dash 10000 -dash-profile live -segment-name output- seg -rap -bs-switching no input.mp4
но когда я выполняется ЦМД с помощью кода Java, я получаю ошибку:
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