tkvideo(n) 1.4.0 tkvideo "tkvideo"


tkvideo - Tk video widget

Table Of Contents



This package provides a Tk widget that can display video streams from streaming video sources or from files. At this time the package only supports DirectShow sources on Windows. It should be possible to extend the backend in the future to support other platforms.


tkvideo pathName ?"option" "value" "..."?

Create a new instance of a video widget and configures it using the provided options and their values.


pathName cget

Returns information about the current configuration of the widget, for the specified option. For options and their meaning see the widget options section.

pathName configure option value ...

Modifies the configuration of the widget. For options and their meaning see the widget options section.

pathName xview

This command is used to query and change the horizontal position of the information in the widget's window.

pathName yview

This command is used to query and change the vertical position of the information in the widget's window

pathName propertypage [ filter | pin ]

This command shows the DirectShow property pages for the video source. There may not be a property page to show, in which case nothing happens. For camera sources it is usually possible to configure the device with these pages. The filter page is the device driver page while the pin page is a lower level DirectShow page.

pathName start

Start streaming the video source. For a file based source this will start at the beginning of the stream. For camera sources the video becomes live.

pathName pause

Pause the video stream.

pathName stop

Stop the stream.

pathName devices

Returns a list of available input devices. An index into this list should be specified for use with the -source configuration option.

pathName picture ?imagename?

Capture a photo image from the video stream. The image name may be specified. If no name is provided then an automatic name is provided using the normal "image photo create" command. The command returns the name of the Tk image created.

pathName tell

Returns a three element list giving the current position, the stop position and the maximum position for the current stream. The stop position is not currently available to be changed but is the location that the current playback will halt at.

pathName seek position

Moves the current seek position to the specified location. The start or the stream will always be 0 and the end of the stream is provided as the third list item returned by the tell command.

pathName volume ?value?

Get or set the volume of the audio channel if one is present. The volume values are a floating-point linear range from silent at 0 to maximum at 100. If no value is provided, the current volume is returned.


Command-Line Switch: -anchor
Database Name: anchor
Database Class: Anchor
Command-Line Switch: -background
Database Name: background
Database Class: Background
Command-Line Switch: -cursor
Database Name: cursor
Database Class: Cursor
Command-Line Switch: -height
Database Name: height
Database Class: Height
Command-Line Switch: -takefocus
Database Name: takeFocus
Database Class: TakeFocus
Command-Line Switch: -width
Database Name: width
Database Class: Width
Command-Line Switch: -xscrollcommand
Database Name: xScrollCommand
Database Class: ScrollCommand
Command-Line Switch: -yscrollcommand
Database Name: yScrollCommand
Database Class: ScrollCommand


Command-Line Switch: -source
Database Name: source
Database Class: Source

This option sets the index of the device to use as a source or may be set to the filename of a file source. At this time WMV and AVI file sources are supported. Some image types can also be used if required. See the devices video command for the list of available capture sources.

Command-Line Switch: -audiosource
Database Name: audiosource
Database Class: AudioSource

Set the audio source. The devices audio command provides a list of available audio sources and an index into this list should be provided here.

Command-Line Switch: -output
Database Name: output
Database Class: Output

If a file name is provided then the video stream may also be saved to file. WMV and AVI files are supported. Note that WMV files require an audio input. AVI files may be video only. The type of file is determined from the file name extension. Set to the empty string to disable file saving.

When recording to file, the file will only be closed and properly completed after the stop command has been called.

Command-Line Switch: -stretch
Database Name: stretch
Database Class: Stretch

The configured video source will have a native size. If this option is false then the video display area will be the video native size and any additional widget space is filled with the background specified for the -background option. The -anchor option is also used to position the video area within the widget.

If this option is true then the display area is stretched or shrunk to fill the widget area. In this case then the -anchor option is ignored, the scrollcommands will not be called and there will be no background visible.


% pack [tkvideo .v -source 0] -expand 1 -fill both
% .v start


Pat Thoyts <>


avi, mpeg, video, webcam