【问题标题】:Reading YUV file in opencv在opencv中读取YUV文件
【发布时间】:2016-12-05 08:43:41
【问题描述】:

我在尝试在 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;
}

但是,我一直遇到以下错误:

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

【问题讨论】:

    标签: visual-studio-2010 opencv ffmpeg


    【解决方案1】:

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

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

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

    【讨论】:

    • 感谢您解决这个问题!我会尝试找到解决方法
    猜你喜欢
    • 2011-01-14
    • 2017-11-21
    • 2023-03-11
    • 1970-01-01
    • 2016-09-04
    • 1970-01-01
    • 2017-03-05
    • 1970-01-01
    • 2015-12-10
    相关资源
    最近更新 更多