当前位置:网站首页>Opencv supports H264 video coding
Opencv supports H264 video coding
2022-07-22 17:05:00 【YQ8023family】
List of articles
Original error will be reported
Mat src;
// use default camera as video source
VideoCapture cap(0);
// check if we succeeded
if (!cap.isOpened()) {
cerr << "ERROR! Unable to open camera\n";
return;
}
// get one frame from camera to know frame size and type
cap >> src;
// check if we succeeded
if (src.empty()) {
cerr << "ERROR! blank frame grabbed\n";
return;
}
bool isColor = (src.type() == CV_8UC3);
//--- INITIALIZE VIDEOWRITER
VideoWriter writer;
int codec = VideoWriter::fourcc('H', '2', '6', '4'/*'P','I','M','1'*//*'M', 'J', 'P', 'G'*/); // select desired codec (must be available at runtime)
double fps = 30.0; // framerate of the created video stream
string filename = "./h264.avi"; // name of the output video file
writer.open(filename, codec, fps, src.size(), isColor);
// check if we succeeded
if (!writer.isOpened()) {
cerr << "Could not open the output video file for write\n";
return;
}
//--- GRAB AND WRITE LOOP
cout << "Writing videofile: " << filename << endl
<< "Press any key to terminate" << endl;
int frame_cnt = 0;
for (;;)
{
// check if we succeeded
if (!cap.read(src) || frame_cnt > 60) {
cerr << "ERROR! blank frame grabbed\n";
break;
}
// encode the frame into the videofile stream
writer.write(src);
frame_cnt += 1;
// show live and wait for a key with timeout long enough to show images
imshow("Live", src);
if (waitKey(5) >= 0)
break;
}
- Wrong content
Solution
According to the error content of the prompt https://github.com/cisco/openh264/releases Go to the website to download the corresponding openh264-1.8.0-win64.dll The file is placed under the current project folder , Execute again to solve
边栏推荐
- 1840. The highest building height is greedy
- [论文翻译] Generalized Radiograph Representation Learning via Cross-Supervision Between Images
- Digital path and practical thinking
- Parse numpy.random.get_ State() and numpy.random.set_ state()
- UE4 合并静态网格体
- UE4 将蓝图写在Actor类里面 实现复用
- 【OPEN HAND】汉得企业级PaaS平台HZERO重磅开源!
- UE4 将画刷制作的物体合并成一个整体
- ES6箭头函数
- 5分钟带你浅谈企业级PaaS平台HZERO!
猜你喜欢
Hzero enterprise level digital PAAS platform (II) | enterprise level authority system
还在写增删改查代码?直接一键生成
Yuanqi Digitalization: existing mode or open source innovation Lixia action
汉得数字平台体系及试用知多少?
FPGA - 7系列 FPGA内部结构之Memory Resources -02- FIFO资源
Mecol Studio - harmonyos second assignment
npm私服发包及使用
Four main steps of web application penetration testing
codeforce D2. RGB Substring (hard version) 滑动窗口
Hiam fine-grained unified authorization management helps enterprises achieve refined management and control of system permissions
随机推荐
ARC110E Shorten ABC
2022/7/19-日报
tf.get_default_graph
【红队】ATT&CK - 浏览器扩展实现持久化
[ARC116F] Deque Game
Concis组件库 | 暗黑模式设计
AT4162 [ARC099C] Independence
汉得企业级PaaS平台HZERO即将重磅开源!
AT2336 [ARC069D] Flags
SAP wper (POS interface monitor) idco posting voucher ALV Report
通过删除注册表破解plsql
arm64环境下,golang的第三方库hajimehoshi/oto依赖alsa-lib和cgo的解决方案
tf.set_random_seed()
HIAM细粒度统一授权管理助力企业实现系统权限精细化管控
ES6箭头函数
数字化路径与实践思考
修复版动态视频壁纸微信小程序源码下载,支持多种类型流量主收益
线程系列协程原理
1143. Longest common subsequence
热忱与专业齐飞 | 微软最有价值专家项目,广纳微软技术贡献者!