ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Video-Capture-V4l/examples/settv
Revision: 1.2
Committed: Sun Feb 24 23:25:11 2002 UTC (22 years, 3 months ago) by pcg
Branch: MAIN
CVS Tags: rel-0_9, rel-0_902, HEAD
Changes since 1.1: +5 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pcg 1.1 #!/usr/bin/perl
2    
3     use Video::Capture::V4l;
4    
5     sub print_capability {
6     my $c=shift;
7     print "Device: ";
8     print "name ",$c->name;
9     print ", type";
10     for (qw(capture tuner teletext overlay chromakey clipping frameram scales monochrome subcapture)) {
11     print " $_" if eval "\$c->$_";
12     }
13     print ", channels ",$c->channels;
14     print ", audios ",$c->audios;
15     print ", sizes ",$c->minwidth,"x",$c->minheight,"-",$c->maxwidth,"x",$c->maxheight;
16     print "\n";
17     }
18    
19     sub print_channel {
20     my $c=shift;
21     print "Channel ",$c->channel,": ";
22     print "name ",$c->name;
23     print ", tuners ",$c->tuners;
24     print ", flags";
25     for (qw(tuner audio)) {
26     print " $_" if eval "\$c->$_";
27     }
28     print ", type";
29     for (qw(tv camera)) {
30     print " $_" if eval "\$c->$_";
31     }
32     # PAL, NTSC, SECAM, PAL-NC, PAL-M, PAL-N, NTSC-Japan
33     print ", norm ",$c->norm;
34     print "\n";
35     }
36    
37     sub print_tuner {
38     my $c=shift;
39     print "Tuner ",$c->tuner,": ";
40     print "name ",$c->name;
41     print ", range ",$c->rangelow,"-",$c->rangehigh;
42     print ", flags";
43     for (qw(pal ntsc secam low norm stereo_on rds_on mbs_on)) {
44     print " $_" if eval "\$c->$_";
45     }
46     print ", mode ",$c->mode;
47     print ", signal ",$c->signal;
48     print "\n";
49     }
50    
51     sub print_audio {
52     my $c=shift;
53     print "Audio Channel ",$c->audio,": ";
54     print "volume ",$c->volume;
55     print ", bass ",$c->bass;
56     print ", treble ",$c->treble;
57     print ", flags";
58     for (qw(mute mutable volume bass treble)) {
59     print " $_" if eval "\$c->$_";
60     }
61     print ", name ",$c->name;
62     print ", mode ",$c->mode;
63     print ", balance ",$c->balance;
64     print ", step ",$c->step;
65     print "\n";
66     }
67    
68     sub print_picture {
69     my $c=shift;
70     print "Picture Settings: ";
71     print "brightness ",$c->brightness;
72     print ", hue ",$c->hue;
73     print ", colour ",$c->colour;
74     print ", contrast ",$c->contrast;
75     print ", whiteness ",$c->whiteness;
76     print ", depth ",$c->depth;
77     print ", palette ",$c->palette;
78     print "\n";
79     }
80    
81     $grab = new Video::Capture::V4l
82     or die "Unable to open Videodevice: $!";
83    
84     print_capability $grab->capability;
85     for (0..$grab->capability->channels-1) {
86     print_channel $grab->channel($_);
87     }
88    
89     for($_=0; my $tuner = $grab->tuner($_); $_++) {
90     last if $tuner->tuner != $_;
91     print_tuner $tuner;
92     }
93    
94     for($_=0; my $audio = $grab->audio($_); $_++) {
95     last if $audio->audio != $_;
96     print_audio $audio;
97     }
98    
99     print_picture $grab->picture;
100    
101     my $channel = $grab->channel (0);
102 pcg 1.2 $channel->norm(MODE_PAL);
103     $channel->set;
104 pcg 1.1 my $tuner = $grab->tuner (0);
105     $tuner->mode(MODE_PAL);
106 pcg 1.2 $tuner->set;
107     my $channel = $grab->channel (1);
108 pcg 1.1 $channel->norm(MODE_PAL);
109     $channel->set;
110    
111     $RTL2 = 154250;
112    
113     print $grab->freq ($RTL2),"\n";
114    
115     $|=1;
116    
117     my $frame=0;
118     my $fr=$grab->capture ($frame, 64, 48);
119    
120     for(;;) {
121     my $nfr = $grab->capture (1-$frame, 64, 48);
122     $grab->sync($frame) or die "unable to sync";
123 pcg 1.2 open X, ">x"; print X $fr; close X;
124 pcg 1.1
125     # save $fr now, as it contains the raw BGR data
126     print ".";
127    
128     $frame = 1-$frame;
129     $fr = $nfr;
130     }
131