If we break into debugger when this codec selection dialog box is open, we can see that it's the result of this call to AVISaveOptions(...)
. So, one way to find out what you picked would be to set a breakpoint on say line 799 and inspect the contents of fourcc
.
However, there is even simpler way:
- Create a dummy video foo.avi with just 1 black frame, selecting the codec using the GUI.
- Open foo.avi using
cv::VideoCapture
.
- Get the
CAP_PROP_FOURCC
from the cv::VideoCapture
instance.
- Decode and print it.
- [Optional] Create a dummy video bar.avi with just 1 black frame, and use the FOURCC code you determined in step 3. Compare foo.avi and bar.avi to verify they are the same.
Sorry, I don't use C#/EmguCV, so I can't provide you an exact example, but the following should be easy enough to port.
C++ Sample
#include <opencv2/opencv.hpp>
#include <iostream>
int main()
{
{
cv::VideoWriter outputVideo;
outputVideo.open("foo.avi", -1, 25.0, cv::Size(640, 480), true);
cv::Mat frame(480, 640, CV_8UC3);
outputVideo.write(frame);
}
cv::VideoCapture inputVideo("foo.avi");
int fourcc = static_cast<int>(inputVideo.get(CV_CAP_PROP_FOURCC));
char FOURCC_STR[] = {
(char)(fourcc & 0XFF)
, (char)((fourcc & 0XFF00) >> 8)
, (char)((fourcc & 0XFF0000) >> 16)
, (char)((fourcc & 0XFF000000) >> 24)
, 0
};
std::cout << "FOURCC is '" << FOURCC_STR << "'\n";
return 0;
}
Console output:
FOURCC is 'DIB '
Python Sample
import cv2
import numpy as np
import struct
outputVideo = cv2.VideoWriter()
outputVideo.open("foo.avi", -1, 25, (640,480), True)
frame = np.zeros((480,640,3), dtype=np.uint8)
outputVideo.write(frame)
outputVideo.release()
inputVideo = cv2.VideoCapture("foo.avi")
fourcc = int(inputVideo.get(cv2.cv.CV_CAP_PROP_FOURCC))
print "FOURCC is '%s'" % struct.pack("<I", fourcc)
Console output:
FOURCC is 'DIB '