-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvidsplit.cpp
More file actions
67 lines (57 loc) · 1002 Bytes
/
vidsplit.cpp
File metadata and controls
67 lines (57 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <cv.h>
#include <highgui.h>
#include <iostream>
/* written by martin scharm
* see http://binfalse.de
*
* split a video streams to png images
*/
using namespace std;
void usage ()
{
cout << "vidsplit --input FILE [--prefix PREFIX]" << endl;
}
int main(int argc, char *argv[])
{
string video = "";
string prefix = "vidsplit_";
int iteration = 0;
for (int i = 1; i < argc; i++)
{
string akt (argv[i]);
if (i < argc - 1)
{
if (akt == "--input")
{
video = argv[i + 1];
i++;
continue;
}
if (akt == "--prefix")
{
prefix = argv[i + 1];
i++;
continue;
}
}
}
if (video.length () < 1)
{
usage ();
return 1;
}
CvCapture *capture = cvCaptureFromAVI(video.c_str());
if (capture)
{
IplImage* frame;
while (frame = cvQueryFrame(capture))
{
stringstream file;
file << prefix << iteration << ".png";
cvSaveImage(file.str ().c_str (), frame);
iteration++;
}
}
cvReleaseCapture( &capture );
return 0;
}