【发布时间】:2018-01-22 23:35:48
【问题描述】:
以下命令在我的 java 模块中不起作用(这会从实时流中获取快照并保存) Runtime.getRuntime().exec("ffmpeg -i \"rtmp://127.0.0.1:1935/live/mytest live=1 timeout=2\" -f image2 -vframes 1 /snaps/testo.jpg");
如果我在 Ubuntu 14.0.4 控制台上使用相同的命令,它可以工作。在 Window 上的 red5pro 模块中使用相同的命令,但在 Ubuntu 上却没有。
当我使用 String[] execStr = {"/usr/local/bin/ffmpeg","-i","rtmp://127.0.0.1:1935/live/mytest","live=1","timeout=2", "-f","image2","-vframes","1","/snaps/tt.jpg"}; ProcessBuilder pb = new ProcessBuilder("ffmpeg -i rtmp://localhost/live/mytest live=1 timeout=2 -f image2 -vframes 1 /snaps/testo.jpg");
它总是抛出找不到流(在 red5pro 控制台中)
【问题讨论】:
-
我认为你的问题是
"rtmp://127.0.0.1:1935/live/mytest","live=1","timeout=2"。您可能会将其组合为一个参数,如"rtmp://127.0.0.1:1935/live/mytest live=1 timeout=2" -
我想我确实尝试过,但让我再试一次
-
现在当我这样做时,我得到以下错误--->RTMP_ReadPacket,未能读取 RTMP 数据包头--->rtmp://127.0.0.1:1935/live/mytest live=1 timeout =2:处理输入时发现无效数据
-
也试试这个:
rtmp://127.0.0.1:1935/live/mytest?live=1&timeout=2 -
现在说:--->rtmp server sent error 以下是我的代码 String[] execStr = {"/usr/bin/ffmpeg", "-i", "rtmp://127.0. 0.1:1935/live/mytest?live=1&timeout=2", "-f", "image2","-vframes", "1","/snaps/ff.jpg"}; ProcessBuilder pb = new ProcessBuilder(execStr); pb.redirectErrorStream(true);进程 p = pb.start(); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));字符串 line2 = null; while ((line2 = in.readLine()) != null) { System.out.println("--->"+line2); } if (p.waitFor() == 0) { }