1
+ #include " testApp.h"
2
+ #include " ofxAVFVideoRecorder.h"
3
+
4
+ // --------------------------------------------------------------
5
+ void testApp::setup (){
6
+ // Test code to generate video
7
+ int width = 640 ;
8
+ int height = 480 ;
9
+ int framerate = 30 ;
10
+ int num_frames = 120 ;
11
+
12
+ ofxAVFVideoRecorder recorder;
13
+ recorder.setup (ofToDataPath (" test.mov" ), width, height, framerate); // must end in .mov extension
14
+ recorder.setAudioFile (ofToDataPath (" audio.wav" ));
15
+
16
+ int arr_size = width*height*4 ;
17
+ unsigned char *data = (unsigned char *)malloc (arr_size*sizeof (unsigned char ));
18
+
19
+ // make test pattern
20
+ int base_q = 10 ;
21
+ int q_amp = 600 ;
22
+ int period = 60 ;
23
+ for (int frame=0 ; frame < num_frames; frame++)
24
+ {
25
+ int q = base_q + 2 * q_amp * (fabs (frame % (period *2 ) - period))/ ((float ) period);
26
+ int x_shift, y_shift, val;
27
+ for (int y=0 ;y<height;y++) {
28
+ for (int x=0 ;x<width;x++) {
29
+
30
+ x_shift = x - width / 2 + frame;
31
+ y_shift = y - height /2 + frame ;
32
+ val = fabs (((x_shift * y_shift + frame) % q) * 255.0 /(float )q);
33
+ int linesize = width * 4 ;
34
+ data[y * linesize + x*4 ] = val ; // r
35
+ data[y * linesize + x*4 +1 ] = val ; // g
36
+ data[y * linesize + x*4 +2 ] = val ; // b
37
+ }
38
+ }
39
+
40
+ recorder.writeRGBA (data); // write frame to video
41
+ }
42
+
43
+ free (data);
44
+
45
+ recorder.finishMovie (); // save movie and add audio
46
+ }
47
+
48
+ // --------------------------------------------------------------
49
+ void testApp::update (){
50
+
51
+ }
52
+
53
+ // --------------------------------------------------------------
54
+ void testApp::draw (){
55
+
56
+ }
57
+
58
+ // --------------------------------------------------------------
59
+ void testApp::keyPressed (int key){
60
+
61
+ }
62
+
63
+ // --------------------------------------------------------------
64
+ void testApp::keyReleased (int key){
65
+
66
+ }
67
+
68
+ // --------------------------------------------------------------
69
+ void testApp::mouseMoved (int x, int y ){
70
+
71
+ }
72
+
73
+ // --------------------------------------------------------------
74
+ void testApp::mouseDragged (int x, int y, int button){
75
+
76
+ }
77
+
78
+ // --------------------------------------------------------------
79
+ void testApp::mousePressed (int x, int y, int button){
80
+
81
+ }
82
+
83
+ // --------------------------------------------------------------
84
+ void testApp::mouseReleased (int x, int y, int button){
85
+
86
+ }
87
+
88
+ // --------------------------------------------------------------
89
+ void testApp::windowResized (int w, int h){
90
+
91
+ }
92
+
93
+ // --------------------------------------------------------------
94
+ void testApp::gotMessage (ofMessage msg){
95
+
96
+ }
97
+
98
+ // --------------------------------------------------------------
99
+ void testApp::dragEvent (ofDragInfo dragInfo){
100
+
101
+ }
0 commit comments