File: record

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 (145 lines) | stat: -rwxr-xr-x 3,230 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/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);
my $tuner = $grab->tuner (0);
$tuner->mode(MODE_PAL);
$channel->norm(MODE_PAL);
$tuner->mode(8);
$tuner->set;
$channel->set;

$RTL2 = 154250;
$RTL2 = 196250;

my $format = PALETTE_YUYV;

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

$|=1;

my($w,$h)=(576,432);

my @dests = (
      "stream1",
      "stream2",
      "stream3",
      );

my $frame=0;
my $fr=$grab->capture($frame, $w, $h, $format);
my $index=0;

for(;;) {
   my $nfr = $grab->capture(1-$frame, $w, $h, $format);
   $grab->sync($frame) or print "unable to sync";

   # save $fr now, as it contains the raw BGR data
   use File::Sync qw/fsync/;
   $index++;
   print ".";
   open FRAME, (sprintf ">%s/frame%08d", $dests[$index % @dests], $index) or die;
   print FRAME $fr;
   close FRAME;

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