From 503c40f6df704c313f6c2d0d97540d5575462ed2 Mon Sep 17 00:00:00 2001 From: Tonton Th Date: Tue, 28 May 2019 14:55:40 +0200 Subject: [PATCH] we can select the output directory --- v4l2/grabvidseq.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/v4l2/grabvidseq.c b/v4l2/grabvidseq.c index 88af9e9..0e7683f 100644 --- a/v4l2/grabvidseq.c +++ b/v4l2/grabvidseq.c @@ -58,6 +58,7 @@ void help(int v) puts("options :"); puts("\t-d /dev/?\tselect video device"); puts("\t-n NNN\t\thow many frames ?"); +puts("\t-O ./\t\tset Output dir"); puts("\t-p NNN\t\tperiod in seconds"); puts("\t-v\t\tincrease verbosity"); exit(0); @@ -83,12 +84,14 @@ int period = 10; /* delai entre les captures */ int nbre_capt = 1; /* nombre de captures */ int opt; double t_debut, t_final; +char dest_dir = ""; /* must have the trailing slash */ -while ((opt = getopt(argc, argv, "d:hn:p:v")) != -1) { +while ((opt = getopt(argc, argv, "d:hn:O:p:v")) != -1) { switch(opt) { case 'd': dev_name = optarg; break; case 'h': help(0); break; case 'n': nbre_capt = atoi(optarg); break; + case 'O': dest_dir = optarg; break; case 'p': period = atoi(optarg); break; case 'v': verbosity++; break; } @@ -179,7 +182,7 @@ for (i = 0; i < nbre_capt; i++) { buf.memory = V4L2_MEMORY_MMAP; xioctl(fd, VIDIOC_DQBUF, &buf); - sprintf(out_name, "out%03d.ppm", i); + sprintf(out_name, "%s/%05d.ppm", dest_dir, i); if (verbosity) fprintf(stderr, "--> %s\n", out_name); fout = fopen(out_name, "w"); @@ -199,7 +202,7 @@ for (i = 0; i < nbre_capt; i++) { } t_final = fimg_timer_get(0); -fprintf(stderr, "elapsed time %g s.\n", t_final); +fprintf(stderr, "elapsed time %g s\n", t_final); type = V4L2_BUF_TYPE_VIDEO_CAPTURE; xioctl(fd, VIDIOC_STREAMOFF, &type);