OpenCVForUnity
OpenCVForUnity copied to clipboard
How to open video stream(stream/video.mjpeg) using OpenCVForUnity?
Hi. I want to get the image frame from the video stream URL. I wrote the code refer to "videoio example" and "https://forum.unity.com/threads/released-opencv-for-unity.277080/page-55#post-7427405". However, I failed to load video stream.
My log message is like these. How to solve this problem??
PS. Current, I opened the video stream using VLC code. However, when I open video using VLC, I should use "TextureToMat" but It uses performance too much. so, I want to get a video frame in the form of a Mat. Is there any way? Could you recommend to me?
Could you try the following steps?
To play streaming file, ffmpeg.dll is required.
1)Download "OpenCV for Windows Version 4.5.5"(https://sourceforge.net/projects/opencvlibrary/).
2)Copy "opencv_videoio_ffmpeg455_64.dll" to "Assets/OpenCVForUntiy/Plugins/Windows/x86_64" folder.
3)Edit User Variables.
https://stackoverflow.com/questions...reply-when-cv2-videocapture-rtsp-onvif-camera
I succeeded in playing this file. BigBuckBunny_115k.mov seems to be a broken link.
//capture.open(Utils.getFilePath(VIDEO_FILENAME)); capture.open("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4", Videoio.CAP_FFMPEG);
Unfortunately I have never used VLC, I would recommend using the AsyncGPUReadback class when converting from RenderTexture to Mat. https://github.com/EnoxSoftware/VideoPlayerWithOpenCVForUnityExample
It just happned to me, too. OpenCV VideoCapture on python can receive rtsp, but OpenCVForUnity can't.
- Unity Editor version: 2022.3.14f1
- OpenCV for Unity version: 2.5.9
- I put the file opencv_videoio_ffmpeg490_64.dll in Assets\OpenCVForUnity\Plugins\Windows\x86_64
- Environment Variable
- OPENCV_FFMPEG_CAPTURE_OPTIONS : rtsp_transport;udp
_videoCapture = new VideoCapture(url); // url is rtsp://... and same url VideoCapture in python can receive.
var ret = _videoCapture.isOpened(); // ret is false
@masaruyoshimura
For the open() method, it is necessary to update the backend to Videoio.CAP_FFMPEG.
//capture.open(Utils.getFilePath(VIDEO_FILENAME)); capture.open("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4", Videoio.CAP_FFMPEG);