The connection to the video stream address reported an error, but direct access to MP4 files is fine

my code

private static String path1 = "D:\\soft\\opencv\\opencv4.5\\build\\x64\\vc15\\bin\\opencv_world455.dll";
    private static String path2 = "D:\\soft\\opencv\\opencv4.5\\build\\bin\\opencv_videoio_ffmpeg455_64.dll";
public static void main(String[] args) {


        VideoCapture cap = new VideoCapture("rtsp://");
            boolean flag;
            Mat image = new Mat();
            flag =;
                System.out.println("--- not able to get image ---");
            HighGui.imshow("video", image);
        System.out.println("--- video capture closed ---");


[ERROR:0@32.270] global C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\videoio\src\cap.cpp (166) cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.5.5) C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): rtsp:// in function ‘cv::icvExtractPattern’

— video capture closed —
Disconnected from the target VM, address: ‘’, transport: ‘socket’

try again in english, please

and while you’re at it, please add getBuildInformation() (probably in Core)

I don’t understand what you mean, are there any reference examples

you’re meant to print / show us some info, like:

System.out.println(Core. getBuildInformation());
1 Like

(I’ve merged the threads. the original first post was partially non-english.)

ok so the build knows ffmpeg… then maybe at runtime a few more DLLs can’t be found.

I think they have to be findable at the time OpenCV is loaded (from PATH), not only after you’ve specifically loaded them from the main() function.

I’m not familiar with OpenCV’s Java bindings, so maybe this is supposed to have worked already?

I am sorry that there is no camera available in my home today, which is a day off, so I cannot test again. I will reply to you next week

This is the configuration of the environment variable, and FFMPEG has been configured

paths to files don’t belong in PATH. PATH must consist of paths to directories only.

warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:808)
warning: rtsp:// (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:809)

I have now replaced the error

please check, if your rtsp stream is visible using e.g. vlc

Thank you for your reply, but I have solved the problem.

After the solution, it is used like this.


org.bytedeco javacv-platform 1.4.4

This dependency needs to be introduced, and the import usage class is imported like this

import org.opencv.core.*;
import org.opencv.highgui.HighGui;
import org.opencv.imgproc.Imgproc;
import org.opencv.videoio.VideoCapture;
import static org.opencv.imgcodecs.Imgcodecs.imencode;
import static org.opencv.imgcodecs.Imgcodecs.imwrite;

Hopefully it will help others as well