Ask Your Question
1

Get fourCC after openning a video file

asked 2015-11-27 15:19:52 -0600

LBerger gravatar image

updated 2015-11-28 08:28:07 -0600

Hi,

Is it possible to get FourCC after openning a video file?

with following code I cannot get FourCC value :

    string filename = "f:/video/installBuild.mp4";  
    VideoCapture cap;
    cap.open(filename);

    if (!cap.isOpened())
    {
        cout << "Could not initialize capturing for camera1...\n";
        return 0;
    }
    cout<< "\nCAP_PROP_POS_AVI_RATIO "<< cap.get(CAP_PROP_POS_AVI_RATIO);
    cout<< "\nCAP_PROP_POS_FRAMES "<< cap.get(CAP_PROP_POS_FRAMES);
    cout<< "\nCAP_PROP_FPS "<< cap.get(CAP_PROP_FPS);
    double x=cap.get(CAP_PROP_FOURCC);
    cout<< "\nCAP_PROP_FOURCC (double)"<<x;
    char *c = (char*)(&x);
    cout << "\nCAP_PROP_FOURCC " << c[0]<< c[1]<< c[2]<< c[4];

and result is

> ***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****
> 
> 
> CAP_PROP_POS_AVI_RATIO 0.04
> CAP_PROP_POS_FRAMES 0 
> CAP_PROP_FPS 25
> CAP_PROP_FOURCC (double)8.75967e+008
> CAP_PROP_FOURCC    
> CAP_PROP_FRAME_COUNT 3536
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-11-28 04:22:54 -0600

LorenaGdL gravatar image

It is possible:

int fourcc = cap.get(CAP_PROP_FOURCC);
string fourcc_str = format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
cout << "CAP_PROP_FOURCC: " << fourcc_str << endl;
edit flag offensive delete link more

Comments

Thanks it's works but I was not able to find in doc. Where is it? (I have used Learning OpenCV: Computer Vision with the OpenCV Library by Gary Bradski,Adrian Kaehler p106)

LBerger gravatar imageLBerger ( 2015-11-28 05:19:17 -0600 )edit
2

It isn't documented afaik. I took it from official test code here: https://github.com/Itseez/opencv/blob..., lines 52-55. Github search on the official repo is quite useful sometimes

LorenaGdL gravatar imageLorenaGdL ( 2015-11-28 05:41:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-27 15:19:52 -0600

Seen: 6,620 times

Last updated: Nov 28 '15