简单的逐帧视频解码器库
我正在寻找一个简单的 c/c++ 库,它允许将视频的第一帧提取为 uchar 数组。并有一个简单的功能来访问下一个。
我知道 FFMPEG,但它需要使用数据包和类似的东西,令我惊讶的是,在网上我找不到一个允许类似以下内容的库:
Video v = openVideo("path"); uchar* 数据 = v.getFrame(); v.nextFrame();
我只需要提取视频帧以将其用作纹理...不需要重新编码或任何其他内容...
当然,能够读取最多格式的东西会很棒,例如基于 libavcodec 构建的东西; p
我正在使用 Windows 7
谢谢!
I'm looking for a simple c/c++ lib that would allow to extract the first frame of a video as a uchar array. And have a simple fonction to access the next one.
I know of FFMPEG but it requiere to play with packet and things like that, and i'm surprised that nowhere on the net i can find a lib that allow something like :
Video v = openVideo("path");
uchar* data = v.getFrame();
v.nextFrame();
I just need to extract frames of a video to use it as a texture...no need for reencoding after or anything...
of course something that would read the most format than possible would be great, something built upon libavcodec for example ;p
And i'm using Windows 7
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是 OpenCV 的一个示例:
它尚未经过测试,但我从一些现有的工作代码中拆解了它,因此不需要很长时间即可使其工作。
cv::Mat_
本质上是一个字节数组。如果您确实需要显式类型为unsigned char *
的内容,那么您可以分配适当大小的空间并使用您可以转换
cv 来迭代矩阵使用像素位置 (
转换为字节数组> 和朋友)。cv::Mat_::at()
) 或迭代器 (cv::Mat_::begin()
) 将 ::Mat库很少将图像数据公开为简单指针的原因有很多,例如:
所以如果你想要你的指针,你必须做一些工作。
Here's an example with OpenCV:
It's untested, but I cannibalized it from some existing working code, so it shouldn't take you long to get it working.
The
cv::Mat_<unsigned char>
is essentially a byte array. If you really need something that's explicitly of typeunsigned char *
, then you can malloc space of the appropriate size and iterate over the matrix usingYou can convert a
cv::Mat
to a byte array using pixel positions(cv::Mat_::at()
) or iterators (cv::Mat_::begin()
and friends).There are many reasons why libraries rarely expose image data as a simple pointer, such as:
So if you want your pointer, you have to do a bit of work for it.
你可以使用 OpenCV,它非常简单,他们的网站上有一个有用的手册 http://opencv.willowgarage.com /维基/
You can use OpenCV it is very simple and they have a useful manual on their site http://opencv.willowgarage.com/wiki/
使用 DirectShow。这是一篇文章: http://www.codeproject.com/KB/audio-视频/framegrabber.aspx
有 DirectShow“附加组件”可以解码不同的视频格式。您可以在以下网站之一获取免费的 DirectShow 过滤器包来解码 DirectShow 不直接支持的一些常见格式: http://www.free-codecs.com/download/DirectShow_FilterPack.htm
Use DirectShow. Here's an article: http://www.codeproject.com/KB/audio-video/framegrabber.aspx
There are DirectShow 'add-ons' to decode different video formats. Here's one of the sites where you can grab free DirectShow filter packs to decode some common formats that are not directly supported by DirectShow: http://www.free-codecs.com/download/DirectShow_FilterPack.htm