I’m going to use the Java provided command line class ProcessBuilder.start() to execute the ffmpege command under Windows to do the push. But when I execute without any errors, I get stuck reading the InputStream message
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);
}
}
enter image description here
I monitored the JVM process using jconsole and found some information.
enter image description here
New contributor
DreamSeeker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.