4
* Copyright (C) 1997,98 Rasca, Berlin
5
* Copyright (C) 2003,04 Karl, Frankfurt
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
#include "../config.h" /* autoconf output */
28
#include <X11/Intrinsic.h>
29
#include <X11/StringDefs.h>
30
#include <X11/Shell.h>
32
#include <X11/extensions/XShm.h>
35
#include <X11/extensions/xf86dga.h>
39
#endif //HasVideo4Linux
50
printf("Usage: %s, ver %s, (c) rasca, berlin 1997,98,99, khb (c) 2003\n", prog, VERSION);
51
printf("[--fps #.#] frames per second (float)\n");
52
printf("[--verbose #] verbose level, '-v' is --verbose 1\n");
53
printf("[--time #.#] time to record in seconds (float)\n");
54
printf("[--frames #] frames to record, don't use it with --time\n");
55
printf("[--continue [yes|no]] autocontinue after maximum frames/time\n");
56
printf("[--cap_geometry #x#[+#+#]] size of the capture window (WIDTHxHEIGHT+X+Y)\n");
57
printf("[--start_no #] start number for the file names\n");
59
printf("[--compress <0-9>] save the frames compressed, '.gz' is added\n");
61
printf("[--use_clone] use the CLON chunk for MNGs if needed\n");
62
printf("[--expand_to_24bit] expand 15/16bpp to 24bpp (only for PPM)\n");
64
printf("[--quality #] quality value for JPEG files (100 - 0)\n");
66
printf("[--source <src>] select input source: x11, shm\n");
67
printf("[--file <file>] file pattern, e.g. out%%03d.xwd\n");
68
printf("[--gui [yes|no]] turn on/off gui\n");
69
#ifdef HAVE_FFMPEG_AUDIO
70
printf("[--audio [yes|no]] turn on/off audio capture\n");
71
printf("[--audio_in <src>] specify audio input device or '-' for pipe input\n");
72
printf("[--audio_rate #] sample rate for audio capture\n");
73
printf("[--audio_bits #] bit rate for audio capture\n");
74
printf("[--audio_channels #] number of audio channels\n");
75
#endif // HAVE_FFMPEG_AUDIO
76
printf("Supported output formats:\n");
77
printf(" X window dump (.xwd)\n");
78
printf(" Portable anymap (.pnm, .pgm, .ppm)\n");
80
printf(" Portable network graphics (.png)\n");
81
printf(" Multiple network graphics (.mng)\n");
84
printf(" Joint picture expert group (.jpg, .jpeg)\n");
86
printf(" MPEG (.mpeg)\n");
92
cleanup_when_interrupted (int signal) {
95
XVC_StopCapture (job);
103
main(int argc, char **argv) {
105
struct option options[] = {
106
{"fps", required_argument, NULL, 0},
107
{"file", required_argument, NULL, 0},
108
{"verbose", required_argument, NULL, 0},
109
{"time", required_argument, NULL, 0},
110
{"frames", required_argument, NULL, 0},
111
{"cap_geometry", required_argument, NULL, 0},
112
{"start_no", required_argument, NULL, 0},
113
{"compress", required_argument, NULL, 0},
114
{"use_clone", no_argument, NULL, 0},
115
{"expand_to_24bit", no_argument, NULL, 0},
116
{"quality", required_argument, NULL, 0},
117
{"bpp", required_argument, NULL, 0},
118
{"source", required_argument, NULL, 0},
119
{"sync", no_argument, NULL, 0},
120
{"step", required_argument, NULL, 0},
121
{"gui", optional_argument, NULL, 0},
122
{"audio", optional_argument, NULL, 0},
123
{"audio_in", required_argument, NULL, 0},
124
{"audio_rate", required_argument, NULL, 0},
125
{"audio_bits", required_argument, NULL, 0},
126
{"audio_channels", required_argument, NULL, 0},
127
{"continue", optional_argument, NULL, 0},
131
int opt_index = 0, c, resultCode; //, flags =0;
133
int dga_evb, dga_errb;
137
app.cap_pos_x = app.cap_pos_y = -1;
141
app.device = "/dev/video0";
147
app.targetCodec = CODEC_MPEG1;
150
app.snddev = "/dev/dsp";
154
// app.flags |= FLG_AUDIO_WANTED;
156
// this is a hook for a GUI to do some pre-init functions ...
157
// possibly to set some fallback options read from a rc file or Xdefaults
158
if (! XVC_PreInit( argc, argv, &app ) ) {
159
fprintf(stderr, "Can't do GUI pre_init ... aborting\n");
163
/* read options file now */
164
XVC_ReadOptionsFile( &app );
167
if (strstr(app.source, "v4l") != NULL) {
168
app.flags |= FLG_USE_V4L;
169
if (strchr(app.source, ':') != NULL) {
170
app.device = strchr(app.source, ':') + 1;
172
} else if (strstr(app.source, "dga") != NULL)
173
app.flags |= FLG_USE_DGA;
174
else if (strstr(app.source, "shm") != NULL)
175
app.flags |= FLG_USE_SHM;
177
while ((c = getopt_long(argc, argv, "v", options, &opt_index)) != -1) {
179
case 0: /* is a long option */
181
case 0: /* frames per second */
182
app.fps = atof(optarg);
184
case 1: /* file for saving */
185
app.file = strdup(optarg);
188
app.verbose = atoi(optarg);
190
case 3: /* time to record */
191
app.time = atof(optarg);
192
if ( app.time != 0 ) app.frames = 0;
195
app.frames = atoi(optarg);
196
if ( app.frames != 0 ) app.time = 0;
198
case 5: /* cap_geometry */
199
sscanf(optarg, "%dx%d+%d+%d", &app.cap_width, &app.cap_height, &app.cap_pos_x, &app.cap_pos_y);
202
app.start_no = atoi(optarg);
205
app.compress = atoi(optarg);
211
app.flags |= FLG_EXPAND_TO_24BIT;
214
app.quality = atoi(optarg);
215
if ((app.quality < 0) || (app.quality > 100))
216
app.quality = 75; /* reset to default */
219
app.bpp = atoi(optarg);
222
app.source = strdup(optarg);
223
if (strstr(optarg, "v4l") != NULL) {
224
app.flags &= ~FLG_SOURCE;
225
app.flags |= FLG_USE_V4L;
226
if (strchr(optarg, ':') != NULL) {
227
app.device = strchr(optarg, ':')+1;
229
} else if (strstr(optarg, "dga") != NULL) {
230
app.flags &= ~FLG_SOURCE;
231
app.flags |= FLG_USE_DGA;
232
} else if (strstr(optarg, "shm") != NULL) {
233
app.flags &= ~FLG_SOURCE;
234
app.flags |= FLG_USE_SHM;
236
app.flags &= ~FLG_SOURCE;
237
printf("using normal x server access ..\n");
241
app.flags |= FLG_SYNC;
244
app.step = atoi(optarg);
251
tmp = (argv[optind][0] == '-')?"yes":argv[optind++];
256
tmp = strdup(optarg);
258
if (strstr(tmp, "no") != NULL) {
259
app.flags |= FLG_NOGUI;
261
app.flags &= ~FLG_NOGUI;
270
tmp = (argv[optind][0] == '-')?"yes":argv[optind++];
275
tmp = strdup(optarg);
277
if (strstr(tmp, "no") != NULL) {
278
app.flags &= ~FLG_AUDIO_WANTED;
280
app.flags |= FLG_AUDIO_WANTED;
285
app.flags |= FLG_AUDIO_WANTED;
286
app.snddev = strdup(optarg);
288
case 18: //audio_rate
289
app.flags |= FLG_AUDIO_WANTED;
290
app.sndrate = atoi(optarg);
292
case 19: //audio_bits
293
app.flags |= FLG_AUDIO_WANTED;
294
app.sndsize = atoi(optarg);
296
case 20: //audio_channels
297
app.flags |= FLG_AUDIO_WANTED;
298
app.sndchannels = atoi(optarg);
305
tmp = (argv[optind][0] == '-')?"yes":argv[optind++];
310
tmp = strdup(optarg);
312
if (strstr(tmp, "no") != NULL) {
313
app.flags &= ~FLG_AUTO_CONTINUE;
315
app.flags |= FLG_AUTO_CONTINUE;
338
app.flags |= FLG_RUN_VERBOSE;
340
app.flags |= FLG_MNG_CLONE;
342
if (app.flags & FLG_USE_V4L) {
343
#ifndef HasVideo4Linux
344
app.flags &= ~FLG_USE_V4L;
345
#else //HasVideo4Linux
348
video = video_open(app.device, O_RDWR);
352
printf("%s:\n cctm=%d channels=%d audios=%d maxwidth=%d "
353
"maxheight=%d minwidth=%d minheight=%d\n",
354
video->name, video->type&VID_TYPE_CAPTURE,
355
video->channels, video->audios, video->maxwidth,
356
video->maxheight, video->minwidth, video->minheight);
358
if (!(video->type & VID_TYPE_CAPTURE)) {
359
fprintf(stderr, "video device can't capture to memory\n");
362
app.cap_width = min(app.cap_width, video->maxwidth);
363
app.cap_height = min(app.cap_height, video->maxheight);
364
app.cap_width = max(app.cap_width, video->minwidth);
365
app.cap_height = max(app.cap_height, video->minheight);
367
#endif //HasVideo4Linux
373
if (app.compress > 9)
378
// these are the hooks for a GUI to create the GUI,
379
// the selection frame, and do some initialization ...
380
if ( ! XVC_CreateGUI(&app) ) {
381
fprintf(stderr, "Can't create GUI ... aborting\n");
384
if ( ! XVC_CreateFrame(&app) ) {
385
fprintf(stderr, "Can't create selection Frame ... aborting\n");
388
if ( ! XVC_InitGUI(&app) ) {
389
fprintf(stderr, "Can't initialize GUI ... aborting\n");
392
if ( app.cap_pos_x >= 0 || app.cap_pos_y >= 0 ) {
393
XVC_ChangeFrame ( app.cap_pos_x, app.cap_pos_y, app.cap_width, app.cap_height, TRUE );
399
switch (app.mouseWanted) {
410
printf("Current settings:\n");
411
printf(" frames per second = %f\n", app.fps);
412
printf(" video encoding = %s\n", tCodecNames[app.targetCodec]);
413
printf(" file pattern = %s\n", app.file);
414
printf(" verbose level = %d\n", app.verbose);
415
printf(" frames to store = %d\n", app.frames);
416
printf(" time to capture = %f sec\n", app.time);
417
printf(" autocontinue = %s\n", ((app.flags & FLG_AUTO_CONTINUE)?"yes":"no"));
419
printf(" compression level = %d\n", app.compress);
422
printf(" quality (jpeg) = %d\n", app.quality);
424
printf(" input source = %s (%d)\n", app.source, app.flags & FLG_SOURCE);
425
printf(" capture pointer = %s\n", mp);
426
#ifdef HAVE_FFMPEG_AUDIO
427
printf(" capture audio = %s\n", ((app.flags & FLG_AUDIO_WANTED)?"yes":"no"));
428
printf(" - input = %s\n", app.snddev);
429
printf(" - sample rate = %i\n", app.sndrate);
430
printf(" - bit rate = %i\n", app.sndsize);
431
printf(" - channels = %i\n", app.sndchannels);
432
#endif // HAVE_FFMPEG_AUDIO
433
printf(" animate command = %s\n", app.play_cmd);
434
printf(" make video command= %s\n", app.video_cmd);
435
printf(" edit frame command= %s\n", app.edit_cmd);
436
printf(" help command = %s\n", app.help_cmd);
439
signal(SIGINT, cleanup_when_interrupted);
441
// this is a hook for the GUI's main loop
442
resultCode = XVC_RunGUI();