如何使用 OpenCV C API 捕获 ffmpeg 流?
我想从 OpenCV C API 读取 ffmpeg 流。
我想要捕获的流媒体是使用 ffmpeg -f avfoundation -i "1" -pix_fmt uyvy422 -f mpegts udp://192.168.1.110:5000 生成的
我尝试使用以下代码读取流
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/videoio/videoio_c.h> //C API VideoCapture()
CvCapture* cap = cvCreateFileCaptureWithPreference("udp://192.168.1.110:5000", CV_CAP_FFMPEG);
cvGrabFrame(stream->cap);
IplImage* frame = cvRetrieveFrame(stream->cap, 0);
问题是框架被设置为NULL并且实际上没有检索到任何内容。
使用C++ API 会很简单,但我无法在我的项目中使用它,我需要C API。
关于如何实施这个有什么想法吗?
I would like to read an ffmpeg stream from OpenCV C API.
The streamer I want to catch is generate using ffmpeg -f avfoundation -i "1" -pix_fmt uyvy422 -f mpegts udp://192.168.1.110:5000
I try to read the stream with the following code
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/videoio/videoio_c.h> //C API VideoCapture()
CvCapture* cap = cvCreateFileCaptureWithPreference("udp://192.168.1.110:5000", CV_CAP_FFMPEG);
cvGrabFrame(stream->cap);
IplImage* frame = cvRetrieveFrame(stream->cap, 0);
The problem is that frame is set to NULL and nothing is actually retrieved.
It will be straightforward using C++ API, but I cannot use it in my project, I need the C API.
Any idea on how to implement this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论