Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: sugesting patch for test_stillpicture



Hi,

Johannes Stezenbach schrieb:
>>>Either use getopt(), or the same getenv() hack used for VIDEODEV.

getopt is a mess like doing basic, at least one evening of
reading, and nothing understood (but who wonders i still
should learn C++ first, don't i?).
anyway i did it the getenv way and wrote some (kinda formatted)
usage info, which is readable, if called in it's directory,
on a 80x25 screen giving examples and all info needed to use the
"features".


Regards Onno

> I use vim and have the following on my ~/.vimrc:
> let c_space_errors=1

P.S.
the .vimrc stuff yields an error for me (.. not a recognized
vimrc command), but using sed is no problem :-)

--- test_stillimage.c	Thu Aug 14 19:40:43 2003
+++ test_stillimage.c-sstime-patch	Wed Oct  8 18:19:57 2003
@@ -3,6 +3,12 @@
  * and mpeg2encode from ftp.mpeg.org, and must have a supported
  * size, e.g. 702x576:
  *   $ convert -sample 702x576\! test.jpg test.mpg
+ *
+ * or more advanced using netpbm and mpeg2enc (not mpeg2encode) :
+ *   $ cat image.jpg | jpegtopnm | pnmscale -xsize=704 -ysize=576 |\
+ *      ppmntsc --pal | ppmtoy4m  -F 25:1 -A 4:3 |\
+ *      mpeg2enc -f 7 -T 90 -F 3 -np -a 2 -o "image.mpg"
+ * 
  */
 
 #include <sys/ioctl.h>
@@ -19,7 +25,13 @@
 
 
 static
-const char *usage_string = "\n\tusage: %s <still.mpg> ...\n\n";
+const char *usage_string = "\n\tusage: %s <still.mpg> [still.mpg ...]\n\n\t
+to use another videodev than the first, set the environment variable VIDEODEV\t
+ e.g.[user@linux]$ export VIDEODEV=\"/dev/dvb/adapter1/video1\".\n
+to display the image <n> seconds, instead of 10, set the variable SSTIME\t
+ e.g. [user@linux]$ export SSTIME=\"60\" to display the still for 1 minute.\n
+this options can be set in the same line as the %s command:\t
+ e.g. $ SSTIME=25 VIDEODEV=/dev/dvb/adapter1/video1 %s ...\n";
 
 
 int main (int argc, char **argv)
@@ -29,15 +41,22 @@
 	struct stat st;
 	struct video_still_picture sp;
 	char *videodev = "/dev/dvb/adapter0/video0";
+	char *env_sstime;
 	int i = 1;
+	int tsec = 10;
 
 	if (argc < 2) {
-		fprintf (stderr, usage_string, argv[0]);
+		fprintf (stderr, usage_string, argv[0],argv[0],argv[0]);
 		return -1;
 	}
 
 	if (getenv ("VIDEODEV"))
 		videodev = getenv("VIDEODEV");
+	
+	if (getenv ("SSTIME")) {
+		env_sstime = getenv("SSTIME");
+		tsec = atoi(env_sstime);
+	}
 
 	if ((fd = open(videodev, O_RDWR)) < 0) {
 		perror(videodev);
@@ -71,8 +90,8 @@
 	}
 	free(sp.iFrame);
 
-	printf("Display image 10 seconds ...\n");
-	sleep(10);
+	printf("Display image %d seconds ...\n",tsec);
+	sleep(tsec);
 	printf("Done.\n");
 	if (argc > ++i)
 		goto next_pic;

Home | Main Index | Thread Index