[mjpeg @ 0x27ee9e0] buffer smaller than minimum size
来源:互联网 发布:linux shell 数值比较 编辑:程序博客网 时间:2024/06/05 19:13
在利用opencv读取视频,去除视频画面上的水印、台标和logo,并重新在生成新的视频。VideoWriter 类出现报错 “[mjpeg @ 0x27ee9e0] buffer smaller than minimum size”,查了很久都没有找到原因。
代码如下:
<span style="font-size:14px;">#include "stdio.h"#include "stdlib.h"#include "time.h"#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>#include "opencv2/photo/photo.hpp"#include <iostream>using namespace std;using namespace cv;int main(){clock_t start, finish;start = clock();cout << "start!!" << endl;string video_path = "/home/dyx/Desktop/test_logs/";VideoCapture capture(video_path + "test.mp4");if (!capture.isOpened())cout << "fail to open!" << endl;//获取帧率double fps =capture.get( CV_CAP_PROP_FPS);cout << "帧率为:" << fps << endl;Size videoSize(capture.get( CV_CAP_PROP_FRAME_WIDTH),capture.get( CV_CAP_PROP_FRAME_HEIGHT));int tem=CV_FOURCC('F', 'L', 'V', '1');cout<<tem<<endl;VideoWriter writer(video_path + "VideoTest.avi", CV_FOURCC('D', 'I', 'V', 'X') , fps, videoSize);//VideoWriter writer(video_path + "VideoTest.avi", CV_FOURCC('F', 'L', 'V', '1'), fps, videoSize);//VideoWriter writer(video_path + "VideoTest264.avi", CV_FOURCC('X', '2', '6', '4'), fps, videoSize);Mat frame;Mat inpainted;Mat inpaintMask = imread("/home/dyx/Desktop/test_logs/log5.jpg");cv::cvtColor(inpaintMask, inpaintMask, CV_BGR2GRAY);int i = 0;while (capture.isOpened()){i++;cout << i << endl;capture >> frame;if (!capture.read(frame)||i>=10000)// get a new frame from camera or video{cout<<"finlish!"<<endl;break;}inpaint(frame, inpaintMask, inpainted, 8, CV_INPAINT_TELEA);writer << inpainted;//cvWaitKey(1000 / fps);if (cvWaitKey(20) == 27){break;}imshow("video", inpainted);}finish = clock();long time = (double)(finish - start) / CLOCKS_PER_SEC;cout << time << endl;printf("时间:%f seconds\n", time);return 0;}</span>
最后,通过调试发现是代码的问题,主要是VideoWriter的videoSize出了问题。把“Size videoSize(CV_CAP_PROP_FRAME_WIDTH,CV_CAP_PROP_FRAME_HEIGHT) ”改为“Size videoSize(capture.get( CV_CAP_PROP_FRAME_WIDTH),capture.get( CV_CAP_PROP_FRAME_HEIGHT))”,即可解决!
因为CV_CAP_PROP_FRAME_WIDTH=3,CV_CAP_PROP_FRAME_HEIGHT=4,即为videoSize(3,4),新生成的视频的宽高太小导致的。视频videoSize的大小最好不要小于videoSize(320,240).
0 0
- [mjpeg @ 0x27ee9e0] buffer smaller than minimum size
- New Memory allocation 1046759 bytes is smaller than the minimum allocation size of 1048576 bytes.
- ORA-01200: actual file size of 1199 is smaller than correct size of 1280 blocks
- ORA-01200: actual file size of 533 is smaller than correct size of 640 blocks
- specified class size for type `CatType' is smaller than the parent type's `GObject
- MXnet报错处理——input image size smaller than input shape
- index file smaller than expected
- git error:index file smaller than expected
- git fatal: index file smaller than expected
- Bad XML block: header size 2370 or total size 0 is larger than data size 0
- Bad XML block :header size 2370 or total size 0 is larger than data size 0
- Buffer size of router
- ftrace buffer size
- MJPEG
- Oracle 安装报SGA size can not be greater than maximum shared memory segment size(0)
- W/ResourceType( 1356): Bad XML block: header size 144 or total size 0 is larger than data size 0
- W/ResourceType( 4896): Bad XML block: header size 215 or total size 0 is larger than data size 0
- Minimum Size Subarray Sum
- tomcat通过urlwrite.xml做301跳转
- 消除恒流源不稳定或电阻分压非线性的影响
- socket编程
- 浙大 PAT Advanced level 1026. Table Tennis (30)
- 数据报协议UDP个人笔记
- [mjpeg @ 0x27ee9e0] buffer smaller than minimum size
- git reset head、checkout
- <<web>>漂亮的相册(二)
- 你程序里的数据放在哪?
- CKEditor的使用方法
- 关于log4Net 没有日志输出的问题
- 用来两个栈实现一个队列。
- logback 常用配置详解(二) <appender>
- 马走日__递归