Hi
Please check this ffmpeg code snippet ( at bottom). This is simple function snapOperation() and this function supposed to take snaps from live stream. The problem is ffmpeg command is not working on my Ubuntu 16 box.
Same code is working on Window. If I fire ffmpeg command on ubuntu console it generate output ( /home/snaps/ff.jpg).
I used same code in Red5Pro and its not working.
Please check this
https://stackoverflow.com/questions/22909434/read-rtmp-live-streaming-vido-data-using-java-code I followed instrcutions from this link.
Also I posted this problem on stackoverflow here https://stackoverflow.com/questions/48391956/ffmpeg-rtmp-not-working-in-my-red5pro-module-on-ubuntu-14-0-4/48424670?noredirect=1#comment83840226_48424670
public void snapOperation()
{
try
{
//here stream name is mytest and generating snap name is ff.jpg
String[] execStr = {"/usr/bin/ffmpeg", “-i”, “rtmp://127.0.0.1:1935/live/mytest”, “live=1”, “timeout=2”, “-f”, “image2”, “-vframes”, “1”, “/home/snaps/ff.jpg”};
//String[] execStr = {"/usr/bin/ffmpeg", “-i”, ““rtmp://127.0.0.1:1935/live/mytest live=1 timeout=2"”, “-f”, “image2”, “-vframes”, “1”, “/home/snaps/ff.jpg”};
//String[] execStr = {”/usr/bin/ffmpeg", “-i”, "“rtmp://127.0.0.1:1935/live/mytest?live=1&timeout=2"”, “-f”, “image2”, “-vframes”, “1”, “/home/snaps/ff.jpg”};
ProcessBuilder pb = new ProcessBuilder(execStr);
//pb.environment().put(“LD_LIBRARY_PATH”,"/usr/lib/:/usr/bin/ffmpeg:/usr/bin/ffprobe:/usr/bin/ffserver:/usr/bin/ffplay");
//pb.environment().put(“LD_LIBRARY_PATH”,"/usr/local/lib:/usr/lib:/lib:/usr/local/bin/ffmpeg:/usr/local/bin/ffprobe");
//pb.environment().put(“PATH”,"/usr/local/lib:/usr/lib:/lib");
pb.redirectErrorStream(true);
Process p = pb.start();
BufferedReader in = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line2 = null;
while ((line2 = in.readLine()) != null)
{
System.out.println(“OUTPUT--------------->”+line2);
}
if (p.waitFor() == 0)
{
}
}
catch (Exception e)
{
// TODO Auto-generated catch block
System.out.println("----------Exception is---------- :"+e.toString());
}
}