Код: Выделить всё
public static void main(String[] args) {
try {
ProcessBuilder builder = new ProcessBuilder("cmd.exe","-C","ffmpeg -re -stream_loop -1 -i D:\\tmp\\video\\ligelHigh1\\1.mp4 -c copy -f rtsp rtsp://127.0.0.1:8554/stream");
Process exec = builder.start();
StringBuilder output = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream()));
String line;
System.out.println("get info");
while ((line = bufferedReader.readLine()) != null) {
System.out.println(line);
output.append(line).append("\n");
}
BufferedReader errorBufferRead = new BufferedReader(new InputStreamReader(exec.getErrorStream()));
String eline;
System.out.println("get error info");
while ((eline = errorBufferRead.readLine()) != null) {
output.append(eline).append("\n");
}
System.out.println("waiting.......");
int wait = exec.waitFor();
System.out.println("process execute end.");
if(wait == 0) {
System.out.println("Success");
System.out.println(output);
}else {
System.out.println("Failure");
System.out.println(output);
}
}catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}
Я отслеживал процесс JVM с помощью jconsole и нашел некоторую информацию.
введите здесь описание изображения
Подробнее здесь: https://stackoverflow.com/questions/788 ... -get-stuck