Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

opencv - How do I convert a Four CC to a file extension?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...