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

**URL:** <https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526>\
**Category:** Android/Java\
**Tags:** videoio\
**Created:** [February 11, 2022, 9:32am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526 "2022-02-11T09:32:04Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 11, 2022, 9:32am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/1 "2022-02-11T09:32:04Z")

</div>

my code

```auto
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’

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 11, 2022, 9:21am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/2 "2022-02-11T09:21:53Z")

</div>

try again in english, please

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 11, 2022, 9:25am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/3 "2022-02-11T09:25:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 11, 2022, 9:27am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/4 "2022-02-11T09:27:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 11, 2022, 9:32am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/5 "2022-02-11T09:32:36Z")

</div>

> [@The connection to the video stream address reported an error, but direct access to MP4 files is fine](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526):
>
> 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 fla…

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 11, 2022, 9:33am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/6 "2022-02-11T09:33:07Z")

</div>

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

```
System.out.println(Core. getBuildInformation());
```

---

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 11, 2022, 9:35am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/8 "2022-02-11T09:35:40Z")

</div>

![1644572116(1)](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/1/165d3d1ca706e9775b0ad306e0230880b0885db1.png)

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 11, 2022, 11:20am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/9 "2022-02-11T11:20:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 11, 2022, 11:22am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/10 "2022-02-11T11:22:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 12, 2022, 4:33am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/11 "2022-02-12T04:33:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 14, 2022, 1:44am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/12 "2022-02-14T01:44:49Z")

</div>

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

 ![1644802958(1)](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/7/70073936df7440729dfbf834f3369dd30b3931ed.png)

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 14, 2022, 10:56pm UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/13 "2022-02-14T22:56:44Z")

</div>

paths to _files_ don’t belong in PATH. PATH must consist of paths to _directories_ only.

---

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 15, 2022, 2:05am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/14 "2022-02-15T02:05:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 15, 2022, 11:14am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/15 "2022-02-15T11:14:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 21, 2022, 9:25am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/16 "2022-02-21T09:25:38Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/f/f5f92c835bd44ed7f3684194d87ec5f26e23725a.png)

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

After the solution, it is used like this.

---

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 21, 2022, 9:29am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/17 "2022-02-21T09:29:18Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/2/2aa1070633bae92427a20f2bc3c0362ea3c7452d.png)

---

<div class="post-metadata">

**Author:** ![zhiqiankun](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhiqiankun](https://forum.opencv.org/u/zhiqiankun)\
**Post date:** [February 21, 2022, 9:31am UTC](https://forum.opencv.org/t/the-connection-to-the-video-stream-address-reported-an-error-but-direct-access-to-mp4-files-is-fine/7526/18 "2022-02-21T09:31:20Z")

</div>

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
