【问题标题】:Fourcc with mac os XFourcc 与 mac os X
【发布时间】:2014-04-24 22:41:50
【问题描述】:

我需要从一系列图像中编写视频。我正在使用此代码:

int main()
{
    //Read sequence of images
    Size frameSize(1360,1024);
    //cout<<path<<endl;
    VideoCapture sequence("path/fr%1d.jpg");
    if (!sequence.isOpened())
       {
           cerr << "Failed to open Image Sequence!\n" << endl;
           return -1;
       }
    //Write video
    VideoWriter oVideoWriter ("path/MyVideo.avi",CV_FOURCC('8','B','P','S'), 15
                              , frameSize);
    Mat imageGrey;
    if(!oVideoWriter.isOpened())
    {
      cout<<"ERROR: Failed to write the video"<<endl;
      return -1;
    }
    Mat Image;
    int i=0;
    while(true)
    {
    sequence>>Image;
    if(Image.empty())
        break;
    cout<<i<<endl;
    Mat imageArr[] = {Image, Image, Image};
    merge(imageArr, 3, imageGrey);
    //cvtColor(Image,imageGrey,CV_GRAY2BGR);
    oVideoWriter.write(imageGrey);
    i++;
    }
    cout<<"video written!"<<endl;
    return 1;
}

与 Windows 7 中的视频相比,我得到一个非常暗的视频。我认为这是编解码器的问题。什么是适用于 mac os x 的最佳编解码器。谢谢

【问题讨论】:

    标签: c++ opencv video codec


    【解决方案1】:

    正如您所说,如果将其与 Windows 进行比较,则可能是编解码器问题。没有最好的编解码器;某些编解码器在特定情况下更好,而在其他情况下更差。使用的常见编解码器可能是使用CV_FOURCC('X', 'V', 'I', 'D') 的 XVID,但不能保证您拥有它。

    第一次运行时,一个好的做法是在 cv::VideoWriter 构造函数中传递 -1 而不是 CV_FOURCC() 宏。将弹出一个窗口,您可以查看可以使用的编解码器类型。当您对其中一个感到满意时,找到该代码的 4CC 代码并将其硬编码到您的程序中。

    您还可以尝试Perian 以在 Mac OS 中访问更多编解码器。

    【讨论】:

      猜你喜欢
      • 2012-08-20
      • 1970-01-01
      • 2011-07-14
      • 2016-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-26
      相关资源
      最近更新 更多