I'm making a program that must process a live video feed and potentially saves the short clips of the feed to a file. Using OpenCV, it's trivial to get the four CC code of the video feed as
#include <opencv2>
int main(int, char**) {
int deviceCode = 0; // Use default camera
cv::VideoCapture cap;
cap(deviceCode);
int fourcc = (int)cap.get(cv::CAP_PROP_FOURCC);
// further processing...
cap.release();
return 0;
}
or
import cv2 as cv
deviceCode = 0 # Use default camera
cap = cv.VideoCapture(deviceCode)
fourcc = int(cap.get(cv.CAP_PROP_FOURCC))
# Further processing...
cap.release()
However, how do I then use the four CC to create the file extension for the filename of the saved video clip? Is there a convenient function in some library that takes in a four CC and returns the file extension as a string?
question from:
https://stackoverflow.com/questions/65948374/how-do-i-convert-a-four-cc-to-a-file-extension 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…