以下命令在我的java模块中不起作用(这是从直播流中截取快照并保存) Runtime.getRuntime().exec("ffmpeg -i \“rtmp://127.0.0.1:1935/Runtime.getRuntime/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 =新ProcessBuilder("ffmpeg -i rtmp://localhost/live/mytest live=1 timeout=2-f image2-vframes 1/snaps/TT.jpg“);
它总是抛出找不到流(在red5pro控制台中)
发布于 2018-01-24 22:19:48
我不懂Java (除了一点,我对FFmpeg很有经验),但我认为你应该像这样写代码:
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(execStr);或者像这样:
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(execStr);我在这里查看:https://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html
https://stackoverflow.com/questions/48391956
复制相似问题