【问题标题】:FFMPEG RTMP not working in my red5pro module on Ubuntu 14.0.4FFMPEG RTMP 在 Ubuntu 14.0.4 上的 red5pro 模块中不起作用
【发布时间】: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) { }

标签: ffmpeg red5pro


【解决方案1】:

我不懂 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

【讨论】:

  • 我确实尝试过。你提到了每个参数之间的空格,是的,我试过了,但没有运气。这里提到了同样的问题:stackoverflow.com/questions/22909434/…
  • 我将不得不为此工作,但以下是错误 rtmp 发送的错误。 NetStrea.Play.StreamNotFound。不存在这样的目录(当我们使用引号时)。发现连接关闭时标头无效(当我们不使用 live=1 时表示流是实时的)
猜你喜欢
  • 1970-01-01
  • 2015-12-20
  • 2015-03-08
  • 2018-05-24
  • 1970-01-01
  • 2016-07-25
  • 1970-01-01
  • 2019-08-20
  • 1970-01-01
相关资源
最近更新 更多