|
@@ -708,38 +708,39 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
*/
|
|
|
public void streamConversion(String code) {
|
|
|
log.info(ffmpegPath + " -re -i /opt/streams/file/" + code + ".mp4 -c:v copy -c:a copy -f rtsp rtsp://124.70.58.209:8554/live/" + code);
|
|
|
- cmdCameraUtil.cmd(ffmpegPath + " -re -i /opt/streams/file/" + code + ".mp4 -c:v copy -c:a copy -f rtsp rtsp://124.70.58.209:8554/live/" + code);
|
|
|
-
|
|
|
-// try {
|
|
|
-// Process proc = Runtime.getRuntime().exec("/bin/bash", null, null);
|
|
|
-// BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
|
|
-// PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())), true);
|
|
|
-// String commit = ffmpegPath+" -re -i /opt/streams/file/"+code+".mp4 -c:v copy -c:a copy -f rtsp rtsp://124.70.58.209:8554/live/"+code;
|
|
|
-// List<String> commands = new ArrayList<>();
|
|
|
-//
|
|
|
-// // 删除
|
|
|
-// commands.add(commit);
|
|
|
-// log.info("HTTP流转RTSP流:{}", commands);
|
|
|
-// for (String line : commands) {
|
|
|
-// out.println(line);
|
|
|
-// }
|
|
|
-// out.println("exit");// 这个命令必须执行,否则in流不结束。
|
|
|
-// String rspLine = "";
|
|
|
-// while ((rspLine = in.readLine()) != null) {
|
|
|
-// System.out.println(rspLine);
|
|
|
-//
|
|
|
-// }
|
|
|
-// int i = proc.waitFor();
|
|
|
-// log.info("执行结果:{}", i);
|
|
|
-//
|
|
|
-// in.close();
|
|
|
-// out.close();
|
|
|
-// proc.destroy();
|
|
|
-// } catch (IOException e) {
|
|
|
-// log.error(e.getMessage());
|
|
|
-// } catch (InterruptedException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
+ try {
|
|
|
+ // 创建ProcessBuilder对象,设置ffmpeg命令及参数
|
|
|
+ ProcessBuilder pb = new ProcessBuilder("ffmpeg", "-re", "-i", "/opt/streams/file/"+code+".mp4", "-c:v", "copy", "-c:a", "copy", "-f", "rtsp", "rtsp://124.70.58.209:8554/live/44");
|
|
|
+
|
|
|
+ // 设置工作目录,如果需要的话
|
|
|
+ pb.directory(new File("/usr/local/bin/ffmpeg"));
|
|
|
+
|
|
|
+ // 启动进程
|
|
|
+ Process process = pb.start();
|
|
|
+
|
|
|
+ // 等待进程执行完成
|
|
|
+ int exitCode = process.waitFor();
|
|
|
+
|
|
|
+ // 打印ffmpeg命令的输出信息
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
|
+ String line;
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
+ log.info("line----"+line);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 打印ffmpeg命令的错误信息
|
|
|
+ BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
|
|
+ String errorLine;
|
|
|
+ while ((errorLine = errorReader.readLine()) != null) {
|
|
|
+ log.info("errorLine----"+errorLine);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 打印ffmpeg命令的退出码
|
|
|
+ System.out.println("Exit Code: " + exitCode);
|
|
|
+ } catch (IOException | InterruptedException e) {
|
|
|
+ log.info("e----"+e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|