| | |
- AVCtrl
- AudioCtrl
- MPTCtrl
- MixerCtrl
- TunerCtrl
- VideoCtrl
- ViewerCtrl
class AVCtrl |
| |
-> AVCtrl
DESCRIPTION
Class that describes a control object for TV and webcam hardware.
Its attributes are sub control objects (not subclasses) such as
video, tuner, viewer. You supply the backend (module) name and its
(main) device number.
CONSTRUCTOR
AVCtrl(str backendname, int devnumber=0)
ATTRIBUTES
AudioCtrl audio
module backend
util.ErrorCollection errcol
list errors
MixerCtrl mixer
MPTCtrl mpt
TunerCtrl tuner
VideoCtrl video
ViewerCtrl viewer
METHODS
quit()
EXAMPLES
avc = AVCtrl('bktr')
avc.backend
-> <module 'bktr' from 'bktr.pyc'>
avc.backend.__name__
-> 'bktr'
avc.mpt
-> None
avc.audio.muted
-> True
avc.video.device.node
-> 0
avc.viewer.pause()
avc.quit() |
| |
Methods defined here:
- __init__(self, backendname, devnumber=0)
- -> AVCtrl
DESCRIPTION
Creates an AVCtrl object, characterized by the attributes backend
(a loaded backend module), errcol (util.ErrorCollection object),
audio (AudioCtrl object or None) mixer (MixerCtrl object or None),
mpt (MPTCtrl object or None), tuner (TunerCtrl object or None),
video (VideoCtrl object or None), and viewer (ViewerCtrl object
or None). All of these are created at init when applicable (e.g.
a webcam doesn't need a TunerCtrl object).
If after creation either backend or video are None, consider your
AVCtrl unusable and quit(). This can be used as a way to probe for
available backends and devices.
EXAMPLES
avc = AVCtrl('bktr')
avc = AVCtrl('saa', 1)
- quit(self)
- -> void
DESCRIPTION
Quits any subsystems (attributes that are not None), closes any
open devices, resets all non-error attributes to None. Use this
or the subsystems' quit() methods to make sure that everything is
cleaned up before dereferencing the object.
EXAMPLES
avc.quit() # Doh!
|
class AudioCtrl |
| |
-> AudioCtrl
DESCRIPTION
Class that describes an audio control object for TV cards. Its
attributes are backend (normally passed by creation of a AVCtrl
container object), source, muted, device, ready, and errors. The
attribute device is a util.Device object, and the attribute ready is
True if init worked (e.g. open device). The attribute errors is
an accumulated list of any error messages that occured when creating
or manipulating the object. As the names suggest, you can change
the audio source and (un)mute. Don't confuse this with the (sound
card) mixer described by MixerCtrl. This is about the audio source
used *by* the TV card, not how it is fed into the sound card.
On saa, there is a provision to set the audio "standard" which means
the type of sound modulation which can be FM-Stereo (A2, D/K1) or
FM-Mono/NICAM. NTSC/PAL M systems may use A2 (Korea) or different
modulations, for which no second IF need be set. This functionality
is obviously very intertwined with tuner functions, and the tuner
function to set the sif1 and sif2 is therefore called internally when
the TV standard is changed. The same function is exposed here as
setStandard(), where you can set A2 (1) or NICAM (0). On other TV
backends, this method has no effect and the attribute standard == 0.
On cxm, if using a PVR150/500, the hardware backend's audio ioctls do
not work, and init will fail. They may work with PVR250/350. It should
not be much of a problem if you get no AudioCtrl (it's not really
relevant for cxm, as audio source switching happens automatically when
videosource gets switched). Therefore, unlike some of the VideoCtrl
and TunerCtrl code, we don't handle these expected errors, but rather
let the AudioCtrl creation fail.
Possibly, you can do without an AudioCtrl, unless you want to be able
to have for example TV video with external audio through your TV card.
But similar functionality can still be had using a MixerCtrl of course.
CONSTRUCTOR
AudioCtrl(module backend, int devnumber=0)
ATTRIBUTES
util.Device device
module backend
list errors
bool muted
bool ready
int source
int standard
METHODS
quit()
setMute(bool mute)
setSource(int src)
setStandard(int std)
EXAMPLES
avc = AVCtrl('bktr') # supply module's name
if avc.audio: # avc.audio is None if its init failed
avc.audio.setSource(0)
if avc.audio.muted: avc.audio.setMute(False)
avc.audio.device.namenode
-> 'tuner0'
avc.quit()
import saa
ac = AudioCtrl(saa) # supply the module itself
ac.backend.__name__
-> 'saa'
ac.device.name
-> 'sau'
ac.quit()
ac = AudioCtrl(saa, 1)
ac.ready # ac is NOT None if init failed!
-> False
ac.device.exists
-> False
ac.errors[-1]
-> 'avctrl.AudioCtrl.__init__(): No such device sau1' |
| |
Methods defined here:
- __init__(self, backend, devnumber=0)
- -> AudioCtrl
DESCRIPTION
Creates an AudioCtrl object, characterized by the attributes
backend (a loaded backend module), source, muted, device,
standard, errors. You supply the backend module object, and if
not 0 the device number to use. If init fails (e.g. device not
present or it's a PVR150/500), the attribute ready will be False,
otherwise True.
EXAMPLES
import bktr
ac0 = AudioCtrl(bktr)
ac1 = AudioCtrl(bktr, 1)
- quit(self)
- -> void
DESCRIPTION
Quits the Audio subsystem, closes the open device, resets all
non-error attributes. Use this to make sure that everything
is cleaned up before dereferencing the object.
EXAMPLES
ac.quit() # Doh!
- setMute(self, mute)
- -> void
DESCRIPTION
(Un)mutes the TV card's audio. Implementations vary, and muting
may appear successful but not work at all. If so, mute your mixer
channel instead. If successful, the attribute muted becomes True
or False reflecting the mute state. If unsuccessful, an error
message is appended to the attribute errors.
EXAMPLES
ac.muted
-> False
ac.setMute(True)
ac.muted
-> True
ac.setMute(False)
- setSource(self, src)
- -> void
DESCRIPTION
Selects the audio source to use, which is one of 0 (tuner/DAC),
1 (external), 2 (ext2 or internal). If successful the attribute
source will be set to the current value. If unsuccessful, an
error message is appended to the attribute errors.
EXAMPLES
ac.source
-> 0
ac.setSource(1)
ac.source
-> 1
- setStandard(self, std)
- -> void
DESCRIPTION
Selects the audio modulation standard to use, which is one of 0
(FM-Mono/NICAM) or 1 (FM-Stereo A2,D/K1). Only useful for saa
backend. It will set the 1st and 2nd intermediate frequencies for
sound according to the current tuner standard and the selected
modulation. If the selected audio standard (1) is not possible
for the current tuner standard, 0 is used instead.
The standard is pre-set to 0 and you must set it if you need 1.
It need not be re-set if changing tuner TV standard.
If successful the attribute standard will be set to the current
value. If unsuccessful, an error message is appended to the
attribute errors.
EXAMPLES
ac.standard
-> 0
ac.setStandard(1)
ac.standard
-> 1
|
class MPTCtrl |
| |
-> MPTCtrl
DESCRIPTION
Class that describes a MPT (Motorized Pan and Tilt) control object
for webcams that have this capability. It doesn't use a special
device, you're expected to already have a VideoCtrl object. Its
attributes are backend (normally passed by creation of a AVCtrl
container object), pan, tilt, panrange, tiltrange, and the boolean
tuple capabilities (canpan, cantilt). Pan and tilt are in degrees
relative to the center of the camera with the pan mirrored so that
it is actually positive or negative from the user's POV, not the
camera's. This is thought to be more intuitive to the user (just
imagine using the left and right arrow keys for panning). The
ranges are tuples (min, max). You should check both. The attribute
errors is an accumulated list of any error messages that occured
when creating or manipulating the object. If init succeeds, the
attribute ready is set to True.
CONSTRUCTOR
MPTCtrl(module backend)
ATTRIBUTES
(bool, bool) capabilities
module backend
list errors
int pan
(int, int) panrange
bool ready
int tilt
(int, int) tiltrange
METHODS
quit()
setPan(int pan)
setTilt(int tilt)
EXAMPLES
avc = AVCtrl('pwc') # supply module's name
avc.mpt is None # avc.mpt is None if its init failed
-> False
avc.mpt.capabilities
-> (True, True)
avc.mpt.pan, avc.mpt.tilt
-> (0, 0)
avc.mpt.panrange, avc.mpt.tiltrange
-> (-70, 70), (-20, 20)
avc.mpt.setPan(-25), avc.mpt.setTilt(10)
avc.mpt.pan, avc.mpt.tilt
-> (-25, 10)
avc.quit()
import pwc
... # create VideoCtrl object (opens device)
mc = MPTCtrl(pwc) # supply the module itself
mc.ready
-> True
mc.backend.__name__
-> 'pwc'
mc.capabilities
-> (True, True) # can pan and tilt
mc.panrange, mc.tiltrange
-> ((-70, 70), (-20, 20))
mc.setPan(-25), mc.setTilt(10)
mc.quit() # may be skipped
mc = MPTCtrl(pwc) # resets camera position
mc.quit() # may be skipped
... # quit VideoCtrl object |
| |
Methods defined here:
- __init__(self, backend)
- -> MPTCtrl
DESCRIPTION
Creates an MPTCtrl object, characterized by the attributes
backend (a loaded backend module), capabilities (a two-tuple of
booleans indicating if the camera can pan, tilt respectively),
pan and tilt (degrees), and panrange and tiltrange (two-tuples
of min, max. Capabilities and ranges are determined on init.
You supply the backend module object. If init fails (e.g. the
video device is not open or the ioctl requesting ranges fails)
or if there's no MPT capability the attribute ready will be
False, otherwise True.
EXAMPLES
import pwc
mc = MPTCtrl(pwc)
mc.ready
-> True
mc.capabilities
-> (True, True)
- quit(self)
- -> void
DESCRIPTION
Quits the MPT subsystem, resets all non-error attributes.
Contrary to most other subsystem's quit() methods this one
is not essential (but should be used for consistency).
EXAMPLES
mc.quit() # Doh!
- setPan(self, pan)
- -> void
DESCRIPTION
Set panning angle, relative to the camera center from the
user's POV. So if you face the camera, a positive pan means
that the cam pans to its left and you see the image (and the
cam) move to your right. If successful the attribute pan will
be set to the current value. If unsuccessful, an error message
is appended to the attribute errors. If you exceed the panrange
limits it will be capped.
EXAMPLES
mc.setPan(10)
mc.pan
-> 10
mc.panrange
-> (-70, 70)
mc.setPan(90)
mc.pan
-> 70
- setTilt(self, tilt)
- -> void
DESCRIPTION
Set tilting angle, relative to the camera center. So if you
face the camera, a positive tilt means the cam tilts up. If
successful the attribute tilt will be set to the current value.
If unsuccessful, an error message is appended to the attribute
errors. If you exceed the tiltrange limits it will be capped.
EXAMPLES
t = mc.tiltrange[0] # min tilt
import time
while t <= mc.tiltrange[1]: # max tilt
mc.setTilt(t)
time.sleep(0.5)
t += 1
|
class MixerCtrl |
| |
-> MixerCtrl
DESCRIPTION
Class that describes a sound mixer control object. Uses ossaudiodev.
Its attributes are channel, volume, muted, device, ready, and
errors. The attribute device is a util.Device object, and the
attribute ready is True if init worked (e.g. open device). The
attribute errors is an accumulated list of any error messages that
occured when creating or manipulating the object. You pass the
backend and the mixer device number (e.g. 1 for /dev/mixer1) on init.
As the names suggest, you can change the current mixer channel,
and set its volume (set to 0 to mute). To use another mixer device,
you should simply create another MixerCtrl. Likewise, because the
mixer device allows concurrent access(*), it's fine to keep the
same device open simultaneously through every backend module if
you find that convenient.
(*) Generally audio and tuner allow this too, but NOT video/capture
The following mixer channels (if available) may be used:
0 = master
1 = pcm
2 = line
3 = mic
4 = cd
5 = line1
6 = line2
7 = video
The volume ranges from 0 to 100. Input values are capped if needed.
CONSTRUCTOR
MixerCtrl(module backend, int devnumber=0)
ATTRIBUTES
int channel
util.Device device
list errors
bool ready
int volume
METHODS
quit()
setChannel(int chan)
setVolume(int vol)
EXAMPLES
avc = AVCtrl('bktr') # supply module's name
if avc.mixer: # avc.mixer is None if its init failed
avc.mixer.setChannel(2)
avc.mixer.device.namenode
-> 'mixer0'
avc.quit()
import saa
mc = MixerCtrl(saa) # supply the module itself
mc.device.name
-> 'mixer'
mc.channel
-> 0
mc1 = MixerCtrl(saa, 1)
mc1.ready # mc is NOT None if its init failed
-> False
mc1.device.exists
-> False
mc1.errors[-1]
-> 'avctrl.MixerCtrl.__init__(): No such device mixer1' |
| |
Methods defined here:
- __init__(self, backend, devnumber=0)
- -> MixerCtrl
DESCRIPTION
Creates an MixerCtrl object, characterized by the attributes
backend (a loaded backend module), channel, volume, device, and
errors. You supply the backend module object, and if not 0 the
device number to use. If init fails (e.g. device not present),
the attribute ready will be False, otherwise True.
EXAMPLES
import bktr
mc, i = [], 0
while i < 4:
mc.append(MixerCtrl(bktr), i)
i += 1
for item in mc:
print item.device.namenode, item.ready, item.channel, item.volume
-> mixer0 True 0 52
mixer1 True 0 48
mixer2 False 0 0
mixer3 False 0 0
- quit(self)
- -> void
DESCRIPTION
Quits the Mixer subsystem, closes the open device, resets all
non-error attributes.
EXAMPLES
mc.quit() # Doh!
- setChannel(self, chan)
- -> void
DESCRIPTION
Selects the mixer channel to use, which is one of 0 to 7. If
too small or too large, chan is silently capped. If successful
the attribute channel will be set to the current value. If
unsuccessful, an error message is appended to the attribute
errors. This includes setting a channel that does not exist,
which can commonly occur with channels such as line2 and video.
EXAMPLES
mc.channel
-> 0
channels, i = [0], 1
while i < 8:
mc.setChannel(i)
if mc.channel == i: # find existing channels
channels.append(i)
i += 1
channels
-> [0, 1, 2, 3, 4, 5, 7] # we have no line2
del mc.errors[-1] # toss the error msg
- setVolume(self, vol)
- -> void
DESCRIPTION
Sets the volume (0 to 100) of the current mixer channel. If
too small or too large, vol is silently capped. If successful
the attribute volume will be set to the current value. If
unsuccessful, an error message is appended to the attribute
errors.
EXAMPLES
mc.volume
-> 100
mc.setVolume(50)
mc.volume
-> 50
|
class TunerCtrl |
| |
-> TunerCtrl
DESCRIPTION
Class that describes a tuner control object for TV cards. Its
attributes are backend (normally passed by creation of a AVCtrl
container object), tunertype, standard, frequency, afc, freqrange,
device, ready, and errors. The attribute device is a util.Device
object, and the attribute ready is True if init worked (e.g. open
device). The attribute errors is an accumulated list of any error
messages that occured when creating or manipulating the object.
As the names suggest, you can set the tuner type, broadcast
standard, frequency, and afc (Automatic Frequency Control) which
is available for bktr and if True the frequency, when set "floats"
to the optimum value in a 5 MHz range. This is software AFC, in
a smaller range many tuners have AFC built in to some extend. So
it's not essential but it can be handy when searching for channels.
The attributes minfreq and maxfreq are set automatically.
API change note: as of v1.96 the frequency is in kHz, not MHz.
The tuner types and broadcast standards are listed below. The fact
that you can make any kind of combination doesn't mean that they
all work or exist. This is roughly the way the saa tuner support
is organized. However, the bktr backend defines its tuners as type
plus standard, and it uses the term SECAM which is not a broadcast
standard. We'll assume D/K there and also use SECAM with L/L'. See
below.
Tuner types: Bktr defines: TUN STD
0 = None 0 = NO_TUNER 0 0
1 = Philips 1 = TEMIC_NTSC 3 5/6
2 = Philips MK3 2 = TEMIC_PAL 3 0
3 = Temic 3 = TEMIC_SECAM 3 1/3/4
4 = Alps 4 = PHILIPS_NTSC 1 5/6
5 = LG 5 = PHILIPS_PAL 1 0
6 = Microtune (bktr) 6 = PHILIPS_SECAM 1 1/3/4
7 = TEMIC_PALI 3 2
Broadcast standards: 8 = PHILIPS_PALI 1 2
9 = PHILIPS_FR1236_NTSC 2 5/6
0 = PAL B/G 10 = PHILIPS_FR1216_PAL 2 0
1 = PAL D/K 11 = PHILIPS_FR1236_SECAM 2 1/3/4
2 = PAL I 12 = ALPS_TSCH5 4 5/6
3 = PAL L 13 = ALPS_TSBH1 4 5/6
4 = PAL L' 14 = TUNER_MT2032 6 0
5 = NTSC 15 = LG_TPI8PSB12P_PAL 5 0
6 = NTSC Japan
If your VideoCtrl object is using a video source other than TV,
tuning will likely not work. Don't rely on it if it does. The
option of autoselecting the standard is not used. If it works
at all, its result is not (always) retrievable.
On cxm the tuner type and broadcast standard are set by firmware
when the kld is loaded and they CAN NOT BE SET OR RETRIEVED after.
Final note on bktr: you need to have your TunerCtrl object ready
to be able to use video picture controls such as brightness and
contrast, because they use the tuner device.
CONSTRUCTOR
TunerCtrl(module backend, int devnumber=0)
ATTRIBUTES
bool afc
util.Device device
module backend
list errors
int frequency
(int, int) freqrange
bool ready
int standard
int tunertype
METHODS
quit()
setAFC(bool afc)
setFrequency(int freq)
setType(int ttype)
setStandard(int std)
EXAMPLES
avc = AVCtrl('bktr') # supply module's name
if avc.tuner: # avc.tuner is None if its init failed
avc.tuner.tunertype # saa: must set this, bktr: must look at
-> 3 # I have a Miro card, Temic PAL
avc.tuner.standard # saa: must set this, bktr: must look at
-> 0
avc.tuner.setAFC(True)
avc.tuner.setFrequency(199000)
avc.tuner.frequency
-> 200000
avc.quit()
import saa
tc = TunerCtrl(saa) # supply the module itself
tc.ready # tc is NOT None if its init failed
-> False
tc.device.name
-> 'iic'
tc.setType(2) # I have a AverMedia card, MK3 tuner, PAL
tc.setStandard(0)
tc.setFrequency(199000)
tc.tuner.frequency
-> 1999000 # No AFC (even if it would be set)
tc.setFrequency(200000)
tc.quit() |
| |
Methods defined here:
- __init__(self, backend, devnumber=0)
- -> TunerCtrl
DESCRIPTION
Creates a TunerCtrl object, characterized by the attributes
backend (a loaded backend module), frequency, freqrange, afc,
tunertype, standard, device, errors. You supply the backend
module object, and if not 0 the device number to use. If init
fails (e.g. device not present), the attribute ready will be
False, otherwise True.
EXAMPLES
import bktr
tc = TunerCtrl(bktr)
tc.ready
-> True
tc.tunertype, tc.standard
-> (3, 0)
- quit(self)
- -> void
DESCRIPTION
Quits the Tuner subsystem, closes the open device, resets all
non-error attributes. Use this to make sure that everything
is cleaned up before dereferencing the object.
EXAMPLES
tc.quit() # Doh!
- setAFC(self, afc)
- -> void
DESCRIPTION
Turn software AFC on or off. If unsuccessful, an error message
is appended to the attribute errors. This works on bktr only
(but is not an error if used on saa).
EXAMPLES
import bktr
tc = TunerCtrl(bktr)
tc.ready
-> True
tc.afc
tc.setAFC(True)
tc.setFrequency(850000)
tc.frequency
-> 848 # here that's discovery channel
- setFrequency(self, freq)
- -> void
DESCRIPTION
Sets the tuner frequency in kHz (int). If successful the
attribute frequency will be set to the current value. If
unsuccessful, an error message is appended to the attribute
errors.
EXAMPLES
import bktr
tc = TunerCtrl(bktr)
tc.ready
-> True
# Lowrange is only for FM, midrange start is same for PAL/NTSC
STEP_NTSC, STEP_PAL, START_OF_MIDRANGE = 6, 8, 160000
channels = []
def look_for_channels(step):
freq = START_OF_MIDRANGE
while freq <= tc.freqrange[1]:
tc.setFrequency(freq)
if ... : # user input or something
channels.append(freq)
freq += steps
tc.setType(2), tc.setStandard(0)
look_for_channels(STEP_PAL)
... # do something with channels
- setStandard(self, std)
- -> void
DESCRIPTION
Selects the broadcast standard, 0 to 6. On bktr, selecting
D/K, L/L' will select - where available - the so-called
SECAM variant and if the user needs genuine PAL D/K selecting
B/G should work (if PAL D/K supported by bktr for that tuner).
On saa, tuner type and broadcast standard selection are not
intertwined. If successful the attribute standard will be set
to the current value. If unsuccessful, an error message is
appended to the attribute errors. Has no effect on cxm.
Note that with saa changing the broadcast standard in general
has the consequence that the sif frequencies for audio need to
be set according to the selected TV standard and in cases where
the standard may have either A2/stereo or NICAM/mono, sound
modulation. The saa backend calls the audio_set_standard
function internally if tuner_set_standard is called, so it need
not be done at this level. However, if you need to change the
modulation type, use the setStandard method of the audio
subsystem (this calls audio_set_standard).
EXAMPLES
import saa
tc = TunerCtrl(saa)
tc.ready
-> True
tc.tunertype, tc.standard
-> (2, 0)
tc.setType(4), tc.setStandard(5)
- setType(self, ttype)
- -> void
DESCRIPTION
Selects the tuner type, 0 to 6. On saa type 6 translates to
type 0 (no tuner). If successful the attribute tunertype
will be set to the current value. On bktr, where implied by
tuner type selection the attribute standard is adjusted if
needed. If unsuccessful, an error message is appended to the
attribute errors. Has no effect with cxm.
EXAMPLES
import bktr
tc = TunerCtrl(bktr)
tc.ready
-> True
tc.tunertype, tc.standard
-> (3, 5)
tc.setType(2), tc.setStandard(0)
|
class VideoCtrl |
| |
-> VideoCtrl
DESCRIPTION
Class that describes a video control object for TV cards and
webcams. Its attributes are backend (normally passed by creation
of a AVCtrl container object), framerate, ready, source,
standard, tunersrc, brightness, contrast, hue, saturation and
errors.
As the names suggest you can set video source, video standard,
tuner device, and the usual brightness, etc. You cannot set the
framerate, but its value is updated when needed. The videosource
is 0 to 4. Most capture boards allow up to 5 CVBS inputs, any of
which may "become" S-Video. Bktr uses 0 to 3 for CVBS and 4 for
SVID. Although the saa backend design allows for up to 4 SVID
sources, the same restrictions as with bktr are being used in my
backend module. This brings us to the tunersrc attribute.
Traditionally, the videosource 1 ("DEV1" or "CVBS2") is known to
be the TV input. However, there were and are card manufacturers
that put it on DEV0. So now there is a method to set it
if needed (defaults to 1). Camera backend modules don't have
this function (see AVCtrl's init for a way to utilize this).
The video standard can be one of 0 to 6
TV cards: Webcams:
0 = AUTO 0 = SQCIF
1 = NTSC 1 = QSIF
2 = NTSC-J 2 = QCIF
3 = PAL 3 = SIF
4 = PAl-M 4 = CIF
5 = PAL-N 5 = 4SIF (VGA)
6 = SECAM 6 = 4CIF
You probably shouldn't trust AUTO all that much. Brightness,
contrast, hue, saturation are set on a 0 to 100 scale. The
attribute errors is an accumulated list of any error messages
that occured when creating or manipulating the object.
The attribute ready is True if init worked. Capture is on.
It can be dangerous to mess around with and therefore turning
capture on and off is not provided as a seperate method. So, if
you instantiate a VideoCtrl vc object and vc.ready is True, your
TV card backend is capturing(*).
(*) pwc webcam capture is done frame by frame in the viewer
subsystem (mainly for simplicity); this is an internal
inconsistency of this framework, however if the container class
AVCtrl is used as intended it isn't really noticable from the
user/developer POV.
Bktr note: To set brightness, contrast, hue, saturation you
should have a valid TunerCtrl object at hand, because it's
actually the tuner device being used for this.
Cxm note: Beware that quite a lot of the controls will not work
(at least with PVR150/500). These are framerate, brightness,
contrast, hue, saturation, and standard. The video standard gets
set automatically by the firmware, but its value can not be
retrieved. Also note that the tunersrc is always 1, and once the
source is set to external, it can not be set back to tuner and you
have no other option but to unload and reload the kernel module.
Therefore, if the source gets set to 0 or 3, it will not really
change. If set to 2 or 4, the user *will* get their composite/svid.
CONSTRUCTOR
VideoCtrl(module backend, int devnumber=0)
ATTRIBUTES
int brightness
int contrast
util.Device device
module backend
list errors
int framerate
int hue
bool ready
int saturation
int source
int standard
int tunersrc
METHODS
quit()
setBrightness(int b)
setContrast(int c)
setHue(int h)
setSaturation(int s)
setSource(int src)
setStandard(int std)
setTunersrc(int src)
EXAMPLES
avc = AVCtrl('saa') # supply module's name
if avc.video:
avc.video.setStandard(3)
avc.video.setTunersrc(1)
avc.video.setSource(avc.video.tunersrc)
avc.video.ready
-> True
avc.video.framerate
-> 25
avc.video.brightness
-> 50
avc.quit()
import pwc
vc = VideoCtrl(pwc) # supply the module itself
vc.ready
-> True
vc.standard
-> 3 # SIF = 320x240 square pixels
vc.framerate
-> 30
vc.setStandard(5) # VGA = double SIF
vc.framerate
-> 15 # camera can't go faster at this res |
| |
Methods defined here:
- __init__(self, backend, devnumber=0)
- -> VideoCtrl
DESCRIPTION
Creates a VideoCtrl object, characterized by attributes such
as backend (a loaded backend module), source, standard, ready,
device, errors. You supply the backend module object, and if
not 0 the device number to use. If init fails (e.g. device not
present or capture fails), the attribute ready will be False,
otherwise True.
EXAMPLES
import bktr
vc0 = VideoCtrl(bktr)
vc1 = VideoCtrl(bktr, 1)
vc0.ready, vc1.ready
-> (True, True)
vc1.device.namenode
-> 'bktr1'
- quit(self)
- -> void
DESCRIPTION
Quits the Video subsystem, closes the open device, resets all
non-error attributes. Use this to make sure that everything
is cleaned up before dereferencing the object.
EXAMPLES
vc.quit() # Doh!
- setBrightness(self, b)
- -> void
DESCRIPTION
Sets the video brightness (0 to 100). If successful the
attribute brightness will be set to the current value.
If unsuccessful, an error message is appended to the
attribute errors.
EXAMPLES
vc.brightness
-> 31
vc.setBrightness(200)
vc.brightness
-> 100
vc.setBrightness(60)
- setContrast(self, c)
- -> void
DESCRIPTION
Sets the video contrast (0 to 100). If successful the
attribute contrast will be set to the current value.
If unsuccessful, an error message is appended to the
attribute errors.
EXAMPLES
vc.contrast
-> 84
vc.setContrast(-1)
vc.contrast
-> 0
vc.setContrast(60)
- setHue(self, h)
- -> void
DESCRIPTION
Sets the video hue (0 to 100). If successful the attribute
hue will be set to the current value. If unsuccessful, an
error message is appended to the attribute errors. The
exact behaviour of this control varies. For example, the
pwc backend uses whitebalance, which is something similar
than hue but not the same. They all allow you to alter the
colors though, and when around 50 they should produce a
"normal" looking color combination.
EXAMPLES
vc.hue
-> 45
vc.setHue(55) # throw some more red in the mix
- setSaturation(self, s)
- -> void
DESCRIPTION
Sets the video saturation (0 to 100). If successful the
attribute saturation will be set to the current value.
If unsuccessful, an error message is appended to the
attribute errors.
EXAMPLES
vc.saturation
-> 20
vc.setSaturation(50)
- setSource(self, src)
- -> void
DESCRIPTION
Selects the video source to use, which is one of 0 to 4.
0 to 3 are for CVBS (TV and composite), 4 is for S-video.
The tuner (TV) source is usually at 1, but may be at 0.
If successful the attribute source will be set to the
current value. If unsuccessful, an error message is
appended to the attribute errors. Does nothing on pwc.
On cxm, the values 1,2,4 work (if using 0,3 no change)
EXAMPLES
vc.source
-> 0 # satellite
vc.setSource(1)
vc.source
-> 1 # tuner
vc.setSource(2) # camera in b/w (luminance component only)
vc.setSource(3) # nothing
vc.setSource(4) # camera (via svideo)
# note how dev2 is actually the same as dev4
- setStandard(self, std)
- -> void
DESCRIPTION
Changes the video standard, which is one of 0 to 6. If
successful, the attribute standard is set to std and the
attribute framerate is updated if needed. If unsuccessful,
an error message is appended to the attribute errors. On
cxm, this only serves to set the capture (encoder) size
to either suit PAL or NTSC. Capture (encoding) is stopped
and started.
EXAMPLES
vc.backend.__name__
->
'bktr'
vc.standard
-> 3
vc.framerate
-> 25
vc.setStandard(1)
vc.framerate
-> 30
- setTunersrc(self, src)
- -> void
DESCRIPTION
Selects the video source to use for TV/tuner, which is one of
0 to 3, so that you can refer to it later. Does nothing on pwc.
EXAMPLES
vc.source
-> 0 # No TV here
vc.setSource(1)
vc.source
-> 1 # Ah, here's TV
vc.setTunersrc(1) # For later reference
vc.tunersrc
-> 1
|
class ViewerCtrl |
| |
-> ViewerCtrl
DESCRIPTION
Class that describes a viewer control object for TV cards and
webcams. Its attributes are backend (normally passed by creation
of a AVCtrl container object), size, paused, fullscreen, ready,
and errors. The attribute ready is True if init worked (e.g.
SDL works). The attribute errors is an accumulated list of any
error messages that occured when creating or manipulating the
object. As the names suggest, you can set the size (a 2-tuple of
integers width,height), toggle pause and fullscreen. Initial
size is (320, 240). On cxm, the viewer is actually a small mpeg2
player (adapted from ffplay), and it will ONLY work if you already
have a VideoCtrl instance (with capture = encoding turned on).
Otherwise the mpeg stream decoder has no data to get started.
CONSTRUCTOR
ViewerCtrl(module backend)
ATTRIBUTES
module backend
list errors
bool fullscreen
bool paused
bool ready
(int, int) size
METHODS
quit()
setFullscreen(bool full)
setPause(bool pause)
setSize(int width, int height)
KEY/MOUSE EVENTS
F: toggle fullscreen
P/SPACE: pause viewer
resize with mouse: resize viewer
EXAMPLES
avc = AVCtrl('saa') # supply module's name
if avc.viewer:
avc.viewer.paused
-> False
avc.viewer.size
-> (320, 240)
avc.viewer.setSize(768, 576)
avc.viewer.setPause(True)
avc.quit()
import pwc
vc = ViewerCtrl(pwc) # supply the module itself
vc.ready
-> True
vc.setSize(654, 321)
vc.size
-> (654, 321)
vc.quit() |
| |
Methods defined here:
- __init__(self, backend)
- -> ViewerCtrl
DESCRIPTION
Creates a ViewerCtrl object, characterized by the attributes
backend (a loaded backend module), fullscreen, paused, errors.
You supply the backend module object. If init fails (e.g. SDL
init fails), the attribute ready will be False, otherwise True.
EXAMPLES
import bktr
vc = ViewerCtrl(bktr)
vc.ready
-> True
vc.size
-> (320, 240)
...
if vc.paused: vc.setPause(False)
if vc.fullscreen: vc.setFullscreen(False)
vc.setSize(480, 640) # this will look a bit silly
vc.size
-> (480, 640)
vc.quit()
- quit(self)
- -> void
DESCRIPTION
Quits the Viewer subsystem, shuts down SDL. Note that with
pwc, which has a read() interface and uses no signalling,
the capture "timing" is actually done using SDL, so in this
case no viewer means no capture.
EXAMPLES
vc.quit() # Doh!
- setFullscreen(self, full)
- -> void
DESCRIPTION
Sets fullscreen mode on or off. The attribute fullscreen
will be set accordingly.
EXAMPLES
import bktr
vc = ViewerCtrl(bktr)
vc.ready
-> True
def toggle_fs():
vc.setFullscreen(not vc.fullscreen)
vc.toggle_fs()
vc.fullscreen
-> True
vc.toggle_fs()
vc.fullscreen
-> False
- setPause(self, pause)
- -> void
DESCRIPTION
Pauses or unpauses the viewer. The attribute paused will be
set accordingly.
EXAMPLES
vc.setPause(True)
vc.paused
-> True
vc.setPause(False)
- setSize(self, width, height)
- -> void
DESCRIPTION
Sets the viewer size (not the capture size). The attribute
size is a 2-tuple (width, height) measured in square pixels,
will be set accordingly.
EXAMPLES
import pwc, time
vc = ViewerCtrl(pwc)
vc.ready
-> True
MINI, SPEED = (100, 75), 2.0
def scary_stuff():
i = 1
while i < 10:
vc.setSize(MINI[0] * i, MINI[1] * i)
time.sleep(1 / SPEED)
i += 1
| |