加载Opencv的视频编写器录制的视频"Could not demultiplex stream"
"Could not demultiplex stream" in loading Video recorded by Opencv's VideoWriter
我的程序是
int main(){
cout << "Start the process" << endl;
cv::VideoCapture vcap("rtsp://root:pass@192.168.0.90/axis-media/media.amp?camera=1");
cout << "Camera connection done!" << endl;
cv::Mat image, small;
//Output video
cv::Size S = cv::Size((int) vcap.get(CV_CAP_PROP_FRAME_WIDTH), (int) vcap.get(CV_CAP_PROP_FRAME_HEIGHT));
int ex = static_cast<int>(vcap.get(CV_CAP_PROP_FOURCC));
int fps = vcap.get(CV_CAP_PROP_FPS);
cout << "fps " << fps << " ex " << ex << endl;
cv::VideoWriter outputVideo;
outputVideo.open("TEST.avi", ex/*CV_FOURCC('X', '2', '6', '4')*/, vcap.get(CV_CAP_PROP_FPS), S, true);
if(!outputVideo.isOpened()){
cout << "Could not open the output video for write" << endl;
return -1;
}
for(;;){
if(!vcap.read(image)){
std::cout << "No frame" << std::endl;
cv::waitKey(0);
}
cv::resize(image, small, image.size()/2, 0, 0 , cv::INTER_LINEAR);
cv::imshow("Display", small);
cv::waitKey(1);
outputVideo.write(small);
if(getkey() == 'n')
break;
}
cout << "Camera release" << endl;
outputVideo.release();
vcap.release();
image.release();
small.release();
return 0;
}
int ex = static_cast<int>(vcap.get(CV_CAP_PROP_FOURCC));
ex在这里。
我可以记录test.avi,但不能由CV :: VideoCapture VCAP读取(" test.avi");或Ubuntu中的VLC播放器或视频。错误是"Could not demultiplex stream"
。
如果我更改为
outputVideo.open("TEST.avi", CV_FOURCC('X', '2', '6', '4'), vcap.get(CV_CAP_PROP_FPS), S, true);
outputVideo.open("TEST.avi", CV_FOURCC('P','I','M','1'), vcap.get(CV_CAP_PROP_FPS), S, true);
outputVideo.open("TEST.avi", CV_FOURCC('M', 'P', '4', '2'), vcap.get(CV_CAP_PROP_FPS), S, true);
etc.
都有相同的问题。
如果我设置
outputVideo.open("TEST.avi", CV_FOURCC('i', 'Y', 'U', 'V'), vcap.get(CV_CAP_PROP_FPS), S, true);
我有错误作为Opencv: FFMPEG iYUV is not supported with codec id 14
outputVideo.open("TEST.avi", CV_FOURCC('M', 'J', 'P', 'G'), vcap.get(CV_CAP_PROP_FPS), S, true);
OpenCV Error: Assertion failed (img.cols == width && img.rows == height && chann
els == 3) in write, file /home/Softwares/opencv/opencv/modules/videoio/src/
cap_mjpeg_encoder.cpp, line 829
terminate called after throwing an instance of 'cv::Exception'
what(): /home/Softwares/opencv/opencv/modules/videoio/src/cap_mjpeg_enco
der.cpp:829: error: (-215) img.cols == width && img.rows == height && channels =
= 3 in function write
可能是什么问题?那是我的ffmpeg有问题吗?
获取大小。就我而言,我这样做了。
`size = images[0].shape[:2]`
尝试播放记录时给出了错误。
`out = cv2.VideoWriter(record_path,fourcc, 15, size)`
我尝试了这个,它是工作的。
`out = cv2.VideoWriter(record_path,fourcc, 15, (size[1],size[0]))`
如果您在使用cv2.imshow显示框架之前从文件中读取视频并调整大小。确保保留"尺寸等于调整大小框架的尺寸。
相关文章:
- 如何在c++中录制具有精确帧时间戳的视频
- 使用 IMFSinkWriter 编码的视频的播放速度会根据宽度而变化
- 如何实时捕获相机的视频?
- 帧提取 使用OpenCV的视频文件开头只有几秒钟
- 使用 OpenCV C++ 每 1 分钟创建新的视频文件
- 从iPhone相机拍摄的视频似乎被OpenCV旋转了90度?我该如何解决这个问题?
- OpenCV没有显示来自Macbook网络摄像头的视频
- 在何处更改参考代码以从 HEVC 编码的视频中提取运动矢量
- 如何使用FFMPEG从编码的视频中提取AVPACKET的重要信息
- 我的视频流程在运行darknet.exe以进行检测对象时崩溃了
- 如何使用Raspberry Pi相机作为C ++ OpenCV中的视频输入
- OpenCV噪声消除静态摄像机的视频
- 如何使用FFMPEG与C拦截编码的视频数据
- 从opencv的视频关注和标量拍摄的图像之间的整数划分
- ARtoolkit加载从4k相机索尼捕获的视频文件
- openCV读取.avi文件的视频捕获获取空框架
- 如何为 OpenCV 的视频编写器动态选择可用的编解码器?
- 从OpenCV C 中的视频文件中检索每三个帧
- 加载Opencv的视频编写器录制的视频"Could not demultiplex stream"
- 在导入的视频上运行 Camshift 演示