FFMPEG RTMP not working in my red5pro module on Ubuntu 14.0.4

334 Views Asked by At

This following command not working in my java module (this takes snap from live stream and save it) Runtime.getRuntime().exec("ffmpeg -i \"rtmp://127.0.0.1:1935/live/mytest live=1 timeout=2\" -f image2 -vframes 1 /snaps/testo.jpg");

If I use same command on Ubuntu 14.0.4 console it works. Same command working in my red5pro module on Window but not on Ubuntu.

When I use 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");

It always throw stream not found ( in red5pro console)

1

There are 1 best solutions below

2
the kamilz On

I don't know Java (except a little, I'm experienced with FFmpeg) but I think you should write the code like this:

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);

or like this:

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);

I checked from here: https://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html