项目实际使用并测试经正式使用无问题,有问题欢迎评论留言
核心后台java代码:
try {
// FFmpeg命令
String command = "ffmpeg -re -i my_video.mp4 -c copy -f flv rtmp://localhost:1935/live/mystream";
// 执行命令
Process process = Runtime.getRuntime().exec(command);
// 获取命令输出流
InputStream inputStream = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// 打印命令输出
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
// 等待命令执行完成
int exitCode = process.waitFor();
System.out.println("Exit code: " + exitCode);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}