Ask Your Question

Revision history [back]

Get fourCC after openning a video file

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

Get fourCC after openning a video file

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