visual-studio-2010 - 在opencv中读取YUV文件

标签 visual-studio-2010 opencv ffmpeg

我在尝试读取 opencv 中的 .yuv 视频文件时遇到了一个特殊问题。我的代码如下:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main( void )
{

    VideoCapture cap("video/balloons1.yuv"); // open the video file for reading

    if ( !cap.isOpened() ) // if not success, exit program
    {
        cout << "Cannot open the video file" << endl;
        return -1;
    }

return 0;
}

但是,我一直遇到以下错误:
enter image description here

我已按照该网站的说明安装了 FFMPEG:http://www.wikihow.com/Install-FFmpeg-on-Windows并且安装似乎是正确的。有没有人知道问题可能是什么?

最佳答案

原始 YUV 视频文件不包含任何元数据,例如图片尺寸、时间、使用的像素格式,甚至不包含任何将文件识别为视频文件的标记。没有额外的帮助,任何玩家都无法打开这个文件,OpenCV 和 ffmpeg 也不能。您需要以某种方式告诉文件的 OpenCV 参数(甚至不确定这是否可能使用 OpenCV api)或将文件转换为其他格式。

我建议做后者。 Using FFMPEG to losslessly convert YUV to another format for editing in Adobe Premier 中描述了可能最简单的方法。 (这将无损压缩视频文件),或者您可以尝试使用某种能够存储原始视频的格式 - IIRC mxf 可以。

请务必为您的特定文件提供正确的详细信息 - 正确的尺寸和像素格式至关重要。

关于visual-studio-2010 - 在opencv中读取YUV文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40965112/

相关文章:

.net - 进入.net Framework System.Web,4.0

visual-studio-2010 - VS2010 Build Deployment Package web.release.config 转换报错

OpenCV 进度条

php - 检测 FFmpeg 安装和版本

javascript - 视频搜索滚动 (60FPS)

visual-studio-2010 - 将 MVC3 应用程序发布到 IIS 错误 - Web 服务器配置为不列出此目录的内容

visual-studio-2010 - TFS SCC : How can I get new files listed in the Pending Changes Panel in Visual Studio

c++ - opencv中3x3矩阵的对数

c++ - 无法释放从 iplimage 创建的 mat 图像

bash - ffmpeg 脚本 mp4 到 mp3