File: settv

package info (click to toggle)
libvideo-capture-v4l-perl 0.224-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 572 kB
  • ctags: 563
  • sloc: ansic: 4,924; perl: 2,746; makefile: 57; sh: 22
file content (131 lines) | stat: -rwxr-xr-x 2,995 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/perl

use Video::Capture::V4l;

sub print_capability {
   my $c=shift;
   print "Device: ";
   print "name ",$c->name;
   print ", type";
   for (qw(capture tuner teletext overlay chromakey clipping frameram scales monochrome subcapture)) {
      print " $_" if eval "\$c->$_";
   }
   print ", channels ",$c->channels;
   print ", audios ",$c->audios;
   print ", sizes ",$c->minwidth,"x",$c->minheight,"-",$c->maxwidth,"x",$c->maxheight;
   print "\n";
}

sub print_channel {
   my $c=shift;
   print "Channel ",$c->channel,": ";
   print "name ",$c->name;
   print ", tuners ",$c->tuners;
   print ", flags";
   for (qw(tuner audio)) {
      print " $_" if eval "\$c->$_";
   }
   print ", type";
   for (qw(tv camera)) {
      print " $_" if eval "\$c->$_";
   }
   # PAL, NTSC, SECAM, PAL-NC, PAL-M, PAL-N, NTSC-Japan
   print ", norm ",$c->norm;
   print "\n";
}

sub print_tuner {
   my $c=shift;
   print "Tuner ",$c->tuner,": ";
   print "name ",$c->name;
   print ", range ",$c->rangelow,"-",$c->rangehigh;
   print ", flags";
   for (qw(pal ntsc secam low norm stereo_on rds_on mbs_on)) {
      print " $_" if eval "\$c->$_";
   }
   print ", mode ",$c->mode;
   print ", signal ",$c->signal;
   print "\n";
}

sub print_audio {
   my $c=shift;
   print "Audio Channel ",$c->audio,": ";
   print "volume ",$c->volume;
   print ", bass ",$c->bass;
   print ", treble ",$c->treble;
   print ", flags";
   for (qw(mute mutable volume bass treble)) {
      print " $_" if eval "\$c->$_";
   }
   print ", name ",$c->name;
   print ", mode ",$c->mode;
   print ", balance ",$c->balance;
   print ", step ",$c->step;
   print "\n";
}

sub print_picture {
   my $c=shift;
   print "Picture Settings: ";
   print "brightness ",$c->brightness;
   print ", hue ",$c->hue;
   print ", colour ",$c->colour;
   print ", contrast ",$c->contrast;
   print ", whiteness ",$c->whiteness;
   print ", depth ",$c->depth;
   print ", palette ",$c->palette;
   print "\n";
}

$grab = new Video::Capture::V4l
   or die "Unable to open Videodevice: $!";

print_capability $grab->capability;
for (0..$grab->capability->channels-1) {
   print_channel $grab->channel($_);
}

for($_=0; my $tuner = $grab->tuner($_); $_++) {
   last if $tuner->tuner != $_;
   print_tuner $tuner;
}

for($_=0; my $audio = $grab->audio($_); $_++) {
   last if $audio->audio != $_;
   print_audio $audio;
}

print_picture $grab->picture;

my $channel = $grab->channel (0);
$channel->norm(MODE_PAL);
$channel->set;
my $tuner = $grab->tuner (0);
$tuner->mode(MODE_PAL);
$tuner->set;
my $channel = $grab->channel (1);
$channel->norm(MODE_PAL);
$channel->set;

$RTL2 = 154250;

print $grab->freq ($RTL2),"\n";

$|=1;

my $frame=0;
my $fr=$grab->capture ($frame, 64, 48);

for(;;) {
   my $nfr = $grab->capture (1-$frame, 64, 48);
   $grab->sync($frame) or die "unable to sync";
   open X, ">x"; print X $fr; close X;

   # save $fr now, as it contains the raw BGR data
   print ".";

   $frame = 1-$frame;
   $fr = $nfr;
}