Q&A
windowsでOpenCVのVideoCaptureでrtspのストリームをひらこうとして苦戦しています
[rtsp @ 035d8320] method SETUP failed: 461 Client error
のようなエラーが出ます。
C++とpythonと両方だめでした。opencvのバージョンはC++が3.3.0(Pythonは4.1.0)です
バージョンが違うのはpythonはPIPで取ってきたからです。
コードは
python
1import cv2 2import numpy as np 3 4# Create a VideoCapture object and read from input file 5# If the input is the camera, pass 0 instead of the video file name 6cap = cv2.VideoCapture("rtsp://192.168.100.142:8554/in.mp4") 7 8# Check if camera opened successfully 9if (cap.isOpened()== False): 10 print("Error opening video stream or file") 11 12# Read until video is completed 13while(cap.isOpened()): 14 # Capture frame-by-frame 15 ret, frame = cap.read() 16 if ret == True: 17 18 # Display the resulting frame 19 cv2.imshow('Frame',frame) 20 21 # Press Q on keyboard to exit 22 if cv2.waitKey(25) & 0xFF == ord('q'): 23 break 24 25 # Break the loop 26 else: 27 break 28 29# When everything done, release the video capture object 30cap.release() 31 32# Closes all the frames 33cv2.destroyAllWindows()
C++
1#include "opencv2/opencv.hpp" 2#include <iostream> 3 4using namespace std; 5using namespace cv; 6 7int main(){ 8 9 // Create a VideoCapture object and open the input file 10 // If the input is the web camera, pass 0 instead of the video file name 11 VideoCapture cap("rtsp://192.168.100.142:8554/in.mp4"); 12 13 // Check if camera opened successfully 14 if(!cap.isOpened()){ 15 cout << "Error opening video stream or file" << endl; 16 return -1; 17 } 18 19 while(1){ 20 21 Mat frame; 22 // Capture frame-by-frame 23 cap >> frame; 24 25 // If the frame is empty, break immediately 26 if (frame.empty()) 27 break; 28 29 // Display the resulting frame 30 imshow( "Frame", frame ); 31 32 // Press ESC on keyboard to exit 33 char c=(char)waitKey(25); 34 if(c==27) 35 break; 36 } 37 38 // When everything done, release the video capture object 39 cap.release(); 40 41 // Closes all the frames 42 destroyAllWindows(); 43 44 return 0; 45} 46
のような感じです。
エラーはC++のときは
[rtsp @ 035d8320] method SETUP failed: 461 Client error
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.h
pp:792)
warning: rtsp://192.168.100.142:8554/in.mp4 (/build/opencv/modules/videoio/src/c
ap_ffmpeg_impl.hpp:793)
(testiii.exe:8152): GLib-GObject-CRITICAL **: 08:19:30.750: g_object_set: assert
ion 'G_IS_OBJECT (object)' failed
Error opening video stream or file
pythonのときは
[rtsp @ 000000000044a740] method SETUP failed: 461 Client error
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.h
pp:901)
warning: rtsp://192.168.100.142:8554/in.mp4 (/build/opencv/modules/videoio/src/c
ap_ffmpeg_impl.hpp:902)
Error opening video stream or file
となります。
C++については1日かけてopencvをgstreamer付きでビルドして見ましたが変わりませんでした。
これから見るにやはりffmpegがキーらしいですが、OpenCV3.3.0のビルドに今使っているffmpegはビルドインで最初からあったものです。(cmake完了時ffmpegの表示がでるが、ON(prebuild binaries)とでる)
たぶんC++でそうだってことはPythonもおなじようなFFMPEGを使ってるのでしょう。最初からONなので考えていませんでしたがこのデフォルトのFFMPEGが今は怪しいと考えております。
で自前でダウンロードしたffmpegを入れるべきか?と考えていますが、(そのffmpegについてきたffplayだとrtspが出せるのは見ている)まずやり方がよくわかりません。LINUXならpkgconfigとかの話だったとおもいますがWINDOWSでもそうなのでしょうか?
そしてなにか全体的に他の案をしっている人はいませんか?
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2019/06/18 01:12
2019/06/18 01:13
2019/06/18 01:41
2019/06/18 06:32 編集
2019/06/18 06:46
2019/06/18 07:22
2019/06/18 12:26
2019/06/21 13:06
2019/06/21 13:34
2019/06/21 23:57