aerdy / Javavision-javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

How to stop FFmpegFrameGrabber when the video is not broadcasting #413

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello everybody,

I have this code, that's works fine:

public void CapturaFotoAutomatic(final String nombre, final String ip, final 
String descripcion) { 
try {
FrameGrabber grabber = new FFmpegFrameGrabber("rtp://" + ip + ":1234");
IplImage img;
grabber.setTimeout(1000);
grabber.start();
img = grabber.grab();
String imagenAuto = "../camaras/" + nombre + ".png";//Modificación para 
obtener de rtp

try {
byte[] b;
b = mergeImageAndText(img.getBufferedImage(), descripcion);
FileOutputStream fos = new FileOutputStream("../camaras/" + nombre + ".png");
fos.write(b);
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
grabber.stop();

}catch (Exception e) {
e.printStackTrace();
}
}

But when the video is not broadcasting, the program waits in the  
grabber.start() instructuion.

How I can finish or kill this instrucction?

How I can detect that the video is not working?

version: javacv_0.7 under windows and linux.

Thanks,

Original issue reported on code.google.com by javier.d...@gmail.com on 21 Jan 2014 at 12:11

GoogleCodeExporter commented 8 years ago
Looks like we need an interrupt handler to add support for a timeout:
http://libav-users.943685.n4.nabble.com/timeout-on-av-read-frame-td3306682.html
http://stackoverflow.com/questions/14558172/ffmpeg-av-read-frame-need-very-long-
time-to-stop 

If anyone feels like implementing that, please let us know! Thanks

Original comment by samuel.a...@gmail.com on 26 Jan 2014 at 4:31