Ask Your Question

Revision history [back]

OpenCV support processing compressed video to frames Java

I can convert video to frames using openCV. But i have another .avi format video which is compressed but i cannot read the video.

Video Info: FileExtension:"avi", Format:"RLE", CodecID: "0*01000000"

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    String filePath = "C:\\Users\\test\\Downloads\\Moni.avi";
    String output = "C:\\Users\\test1\\Downloads\\Test";

    if (!Paths.get(filePath).toFile().exists()) {
        System.out.println("File " + filePath + " does not exist!");
        return;
    }

    VideoCapture video = new VideoCapture(filePath);
    Mat frame = new Mat();

    System.out.println(video.read(frame));
    video.open(filePath);
    System.out.println(video.grab());

    if(video.isOpened()) {
        System.out.println("Test");


    int video_length = (int) video.get(Videoio.CAP_PROP_FRAME_COUNT);
    int frames_per_second = (int) video.get(Videoio.CAP_PROP_FPS);
    int frame_number = 0;

    System.out.println(video_length);
    System.out.println(frames_per_second);

    if (video.read(frame))
    {
        for (int i = 0; i < video_length; i++) {
            System.out.println("Frame Obtained");
            System.out.println("Captured Frame Width " + frame.width() + " Height " + frame.height());
            Imgcodecs.imwrite(output + "/" + frame_number + ".jpg", frame);
            System.out.println("OK");
            frame_number++;
        }
    }

    matToBufferedImage(frame);
    video.release();
        }

OpenCV support processing compressed video to frames Java

I can convert video to frames using openCV. But i have another .avi format video which is compressed but i cannot read the video.

Video Info: FileExtension:"avi", Format:"RLE", CodecID: "0*01000000"

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    String filePath = "C:\\Users\\test\\Downloads\\Moni.avi";
    String output = "C:\\Users\\test1\\Downloads\\Test";

    if (!Paths.get(filePath).toFile().exists()) {
        System.out.println("File " + filePath + " does not exist!");
        return;
    }

    VideoCapture video = new VideoCapture(filePath);
    Mat frame = new Mat();

    System.out.println(video.read(frame));
    video.open(filePath);
    System.out.println(video.grab());

    if(video.isOpened()) {
        System.out.println("Test");


    int video_length = (int) video.get(Videoio.CAP_PROP_FRAME_COUNT);
    int frames_per_second = (int) video.get(Videoio.CAP_PROP_FPS);
    int frame_number = 0;

    System.out.println(video_length);
    System.out.println(frames_per_second);

    if (video.read(frame))
    {
        for (int i = 0; i < video_length; i++) {
            System.out.println("Frame Obtained");
            System.out.println("Captured Frame Width " + frame.width() + " Height " + frame.height());
            Imgcodecs.imwrite(output + "/" + frame_number + ".jpg", frame);
            System.out.println("OK");
            frame_number++;
        }
    }

    matToBufferedImage(frame);
    video.release();
        }

OpenCV support processing compressed video to frames Java

I can convert video to frames using openCV. But i have another .avi format video which is compressed but i cannot read the video.

Video Info: FileExtension:"avi", Format:"RLE", Format:"Microsoft RLE", CodecID: "0*01000000"

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    String filePath = "C:\\Users\\test\\Downloads\\Moni.avi";
    String output = "C:\\Users\\test1\\Downloads\\Test";

    if (!Paths.get(filePath).toFile().exists()) {
        System.out.println("File " + filePath + " does not exist!");
        return;
    }

    VideoCapture video = new VideoCapture(filePath);
    Mat frame = new Mat();

    System.out.println(video.read(frame));
    video.open(filePath);
    System.out.println(video.grab());

    if(video.isOpened()) {
        System.out.println("Test");


    int video_length = (int) video.get(Videoio.CAP_PROP_FRAME_COUNT);
    int frames_per_second = (int) video.get(Videoio.CAP_PROP_FPS);
    int frame_number = 0;

    System.out.println(video_length);
    System.out.println(frames_per_second);

    if (video.read(frame))
    {
        for (int i = 0; i < video_length; i++) {
            System.out.println("Frame Obtained");
            System.out.println("Captured Frame Width " + frame.width() + " Height " + frame.height());
            Imgcodecs.imwrite(output + "/" + frame_number + ".jpg", frame);
            System.out.println("OK");
            frame_number++;
        }
    }

    matToBufferedImage(frame);
    video.release();
        }

OpenCV support processing compressed video to frames Java

I can convert video to frames using openCV. But i have another .avi format video which is compressed but i cannot read the video.

Video Info: FileExtension:"avi", Format:"Microsoft RLE", CodecID: "0*01000000"

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    String filePath = "C:\\Users\\test\\Downloads\\Moni.avi";
    String output = "C:\\Users\\test1\\Downloads\\Test";

    if (!Paths.get(filePath).toFile().exists()) {
        System.out.println("File " + filePath + " does not exist!");
        return;
    }

    VideoCapture video = new VideoCapture(filePath);
    Mat frame = new Mat();

    System.out.println(video.read(frame));
    video.open(filePath);
    System.out.println(video.grab());

    if(video.isOpened()) {
        System.out.println("Test");


    int video_length = (int) video.get(Videoio.CAP_PROP_FRAME_COUNT);
    int frames_per_second = (int) video.get(Videoio.CAP_PROP_FPS);
    int frame_number = 0;

    System.out.println(video_length);
    System.out.println(frames_per_second);

    if (video.read(frame))
    {
        for (int i = 0; i < video_length; i++) {
            System.out.println("Frame Obtained");
            System.out.println("Captured Frame Width " + frame.width() + " Height " + frame.height());
            Imgcodecs.imwrite(output + "/" + frame_number + ".jpg", frame);
            System.out.println("OK");
            frame_number++;
        }
    }

    matToBufferedImage(frame);
    video.release();
        }