| 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 |
my $tuner = $grab->tuner (0); |
| 103 |
$tuner->mode(TUNER_PAL); |
| 104 |
$channel->norm(MODE_PAL); |
| 105 |
$tuner->set; |
| 106 |
$channel->set; |
| 107 |
|
| 108 |
$RTL2 = 154250; |
| 109 |
$RTL2 = 196250; |
| 110 |
|
| 111 |
print $grab->freq ($RTL2),"\n"; |
| 112 |
|
| 113 |
$|=1; |
| 114 |
|
| 115 |
my $frame=0; |
| 116 |
my $fr=$grab->capture ($frame, 640, 480); |
| 117 |
|
| 118 |
for(;;) { |
| 119 |
my $nfr = $grab->capture (1-$frame, 640, 480); |
| 120 |
$grab->sync($frame) or die "unable to sync"; |
| 121 |
|
| 122 |
# save $fr now, as it contains the raw BGR data |
| 123 |
print "."; |
| 124 |
|
| 125 |
$frame = 1-$frame; |
| 126 |
$fr = $nfr; |
| 127 |
} |
| 128 |
|