opencv: cv::cudacodec::VideoReader unable to Play rtsp stream
System information (version)
- OpenCV => 3.3.0
- Operating System / Platform => Ubuntu 16.04, x86_64
- Compiler => gcc version 5.4.1 20160904
- Cuda => 8.0
- Nvidia card => GTX 1080 Ti
Detailed description
i am trying to play a rtsp stream using cudacodec::VideoReader
Rtsp Stream Details ( from vlc )
this stream plays fine in vlc and
cv::VideoCapture
but when i try to play it in cudacodec::VideoReader
i get a error saying:
OpenCV Error: Gpu API call (CUDA_ERROR_FILE_NOT_FOUND [Code = 301]) in CuvidVideoSource, file /home/sumit/Downloads/softwares/opencv/modules/cudacodec/src/cuvid_video_source.cpp, line 66
Invalid UE golomb code
Invalid UE golomb code
OpenCV Error: Unsupported format or combination of formats (Unsupported video source) in FFmpegVideoSource, file /home/sumit/Downloads/softwares/opencv/modules/cudacodec/src/ffmpeg_video_source.cpp, line 110 terminate called after throwing an instance of 'cv::Exception'
what(): /home/sumit/Downloads/softwares/opencv/modules/cudacodec/src/ffmpeg_video_source.cpp:110: error: (-210) Unsupported video source in function FFmpegVideoSource
Steps to reproduce
#include "opencv2/opencv_modules.hpp"
#if defined(HAVE_OPENCV_CUDACODEC)
#include <opencv2/core.hpp>
#include <opencv2/cudacodec.hpp>
#include <opencv2/highgui.hpp>
int main(int argc, const char* argv[])
{
const std::string fname = "rtsp://admin:admin@192.168.1.13/media/video2";
cv::namedWindow("GPU", cv::WINDOW_NORMAL);
cv::cuda::GpuMat d_frame;
cv::Ptr<cv::cudacodec::VideoReader> d_reader = cv::cudacodec::createVideoReader(fname);
for (;;)
{
if (!d_reader->nextFrame(d_frame))
break;
cv::Mat frame;
d_frame.download(frame);
cv::imshow("GPU", frame);
if (cv::waitKey(3) > 0)
break;
}
return 0;
}
#else
int main()
{
std::cout << "OpenCV was built without CUDA Video decoding support\n" << std::endl;
return 0;
}
#endif
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21
@Adonishl I had a similar problem where a stream from a ip camera was playing perfectly in vlc but was not being played by
cv::cudacodec::VideoReader
even after building it with FFMPEG.You should check if the codec and pixel format of your stream (as shown in vlc) are they supported in the
InputMediaStream_FFMPEG::open
method.What i found out in my case was that while vlc detected the pixel format of stream as YUV420P, ffmpeg detected it as YUVJ420P so i made the below mentioned change here
and it worked for me.
You should try debugging
InputMediaStream_FFMPEG::open
and see what is happening.