我想知道如何在使用 VideoCapture(在 OSX 或 Ubuntu 上)打开视频文件后打印出其编解码器。
该文件在 qt 应用程序中由 opencv 正确加载和可视化。
QString filename = QFileDialog::getOpenFileName(...)
cout << filename.size() << endl; // size in byte
VideoCapture cap = VideoCapture(filename.toStdString());
cout << cap.get(CV_CAP_PROP_FRAME_HEIGHT) << endl; // print the height
cout << cap.get(CV_CAP_PROP_FPS) << endl; // print the fps
codec ??
最佳答案
尝试
cap.get(CV_CAP_PROP_FOURCC);
获取编解码器。
编辑: 我不是 C++ 程序员,但这是我四处寻找以将其更改为 char 数组的结果:
int ex = static_cast<int>(inputVideo.get(CV_CAP_PROP_FOURCC));
char EXT[] = {ex & 0XFF , (ex & 0XFF00) >> 8,(ex & 0XFF0000) >> 16,(ex & 0XFF000000) >> 24, 0};
参见: http://docs.opencv.org/doc/tutorials/highgui/video-write/video-write.html
关于Qt 或 OpenCV : print out the codec of a video file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16108298/