1 | initial version |
okay i got it myself ;) I will add the source code. It works in an loop but you could change that easily ;)
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.File;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.videoio.VideoCapture;
import org.opencv.videoio.VideoWriter;
import org.opencv.videoio.Videoio;
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.load(new File("lib/opencv_java341.dll").getAbsolutePath());
System.load(new File("lib/opencv_ffmpeg341_64.dll").getAbsolutePath());
System.load(new File("lib/opencv_world341.dll").getAbsolutePath());
System.load(new File("lib/openh264-1.7.0-win64.dll").getAbsolutePath());
Mat image = new Mat();
VideoCapture videoCapture = new VideoCapture("http://192.168.0.90/mjpg/video.mjpg");
Size frameSize = new Size((int) videoCapture.get(Videoio.CAP_PROP_FRAME_WIDTH), (int) videoCapture.get(Videoio.CAP_PROP_FRAME_HEIGHT));
VideoWriter videoWriter = new VideoWriter("heuter.avi", VideoWriter.fourcc('x', '2','6','4'),
videoCapture.get(Videoio.CAP_PROP_FPS), frameSize, true);
int i = 0;
while (i < 1000) {
videoCapture.read(image);;
videoWriter.write(image);
System.out.println(i);
i++;
}
videoWriter.release();
videoCapture.release();
System.out.println("hier");
}
}