flv_reproducer.cpp

flv format writer reproducer - Alexander Smorkalov, 2012-11-29 12:26 pm

Download (1 kB)

 
1
#include "opencv2/highgui/highgui.hpp"
2
#include <vector>
3
#include <stdio.h>
4
5
using namespace cv;
6
7
int main(int argc, char** argv)
8
{
9
    if (argc < 2)
10
    {
11
        printf("Error. Pass output file name as a parameter\n");
12
        return -1;
13
    }
14
15
    VideoCapture capture(0);
16
    int fWidth = capture.get(CV_CAP_PROP_FRAME_WIDTH);
17
    int fHeight = capture.get(CV_CAP_PROP_FRAME_HEIGHT);
18
19
    if (!capture.isOpened())
20
    {
21
        printf("Error: cannot open camera\n");
22
        return -1;
23
    }
24
25
    printf("Video camera opened with resolition %dx%d\n", fWidth, fHeight);
26
27
28
    printf("Before video writer constructor\n");
29
    VideoWriter writer;
30
    printf("After video writer constructor\n");
31
    writer.open(argv[1], CV_FOURCC('F', 'L', 'V', '1'), 24, Size(fWidth, fHeight));
32
    printf("After video writer.open()\n");
33
34
35
    Mat frame;
36
    for (int i = 0; i < 25; i++) {
37
        printf("Grub frame\n");
38
        capture >> frame;
39
        if (frame.empty())
40
            break;
41
42
        printf("Write frame\n");
43
        writer.write(frame);
44
    }
45
46
    return 0;
47
}