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) {

        //必须要加入这两个东西,在opencv的安装目录下可以找到这两个文件
        System.load(path1);
        System.load(path2);

        VideoCapture cap = new VideoCapture("rtsp://10.73.130.119:8854/live");
        while(cap.isOpened()){
            boolean flag;
            Mat image = new Mat();
            flag = cap.read(image);
            if(!flag){
                System.out.println("--- not able to get image ---");
                break;
            }
            HighGui.imshow("video", image);
            HighGui.waitKey(10);
        }
        System.out.println("--- video capture closed ---");
    }

console

[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://10.73.130.119:8854/live in function ‘cv::icvExtractPattern’

— video capture closed —
Disconnected from the target VM, address: ‘127.0.0.1:54345’, 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://10.73.130.119:8854/live (/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.

image

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 java.io.ByteArrayInputStream;
import java.io.InputStream;
import static org.opencv.imgcodecs.Imgcodecs.imencode;
import static org.opencv.imgcodecs.Imgcodecs.imwrite;

Hopefully it will help others as well