Table Of Contents
- Video
VideoBaseVideoBase.bufferingVideoBase.durationVideoBase.filenameVideoBase.generate_thumbnail()VideoBase.load()VideoBase.on_buffering()VideoBase.optionsVideoBase.pause()VideoBase.play()VideoBase.positionVideoBase.seek()VideoBase.stateVideoBase.stop()VideoBase.textureVideoBase.unload()VideoBase.volume
Video¶
Core class for reading video files and managing the video
Texture.
Changed in version 3.0.0: Extended VideoBase with:
VideoBase.generate_thumbnail()classmethod for creating aTexturefrom a frame at a given timestamp without instantiating / playing the video.
VideoBase.bufferingobservable boolean that is True while playback is delayed/stalled while trying to satisfystate='play', and theVideoBase.on_bufferingevent that fires whenever it changes.
VideoBase.optionsprovider-specific options dict so apps can pass opaque configuration through to the backend implementation. Each provider documents the keys it honors.
Changed in version 1.10.0: The pyglet, pygst and gi providers have been removed.
Changed in version 1.8.0: There are now 2 distinct Gstreamer implementations: one using Gi/Gst working for both Python 2+3 with Gstreamer 1.0, and one using PyGST working only for Python 2 + Gstreamer 0.10.
Note
Recording is not supported.
- class kivy.core.video.VideoBase(**kwargs)¶
Bases:
kivy.event.EventDispatcherVideoBase, a class used to implement a video reader.
- Parameters:
- filename: str
Filename of the video. Can be a file or an URI.
- eos: str, defaults to ‘pause’
Action to take when EOS is hit. Can be one of ‘pause’, ‘stop’ or ‘loop’.
Changed in version 1.4.0: added ‘pause’
- async: bool, defaults to True
Load the video asynchronously (may be not supported by all providers).
- autoplay: bool, defaults to False
Auto play the video on init.
- options: dict, defaults to {}
Provider-specific options forwarded opaquely to the underlying implementation. The base class consumes the documented kwargs above; any other keys are placed in
optionsfor the selected provider to consume. Each provider documents the keys it honors. Keys not recognized by the selected provider are typically logged as a warning and ignored.New in version 3.0.0.
- Events:
- on_eos
Fired when EOS is hit.
- on_load
Fired when the video is loaded and the texture is available.
- on_frame
Fired when a new frame is written to the texture.
- on_buffering
Fired when
bufferingchanges. Strictly a transition event; the boolean is also readable as a property.New in version 3.0.0.
- property buffering¶
Whether playback is currently delayed/stalled while trying to satisfy
state='play'. Always False whilestateis'pause'or'stop'(the player is doing what was asked; there is no delay relative to intent).Truecovers both the initial pre-playback wait (asset still loading, buffer still filling) and any mid-stream rebuffer. Providers update this from their own authoritative signal; providers that cannot detect stalls leave itFalse. Apps that want a loading overlay can usenot video.loaded or video.bufferingas the gate.New in version 3.0.0.
- property duration¶
Get the video duration (in seconds)
- property filename¶
Get/set the filename/uri of the current video
- classmethod generate_thumbnail(filename, time, size=None)¶
Generate a thumbnail
Texturefrom the given video file at the given timestamp, without requiring playback.- Parameters:
- filename: str
Path or URI to the video.
- time: float
Timestamp in seconds at which to grab the thumbnail.
- size: tuple of (int, int), optional
Target
(width, height). WhenNonethe source video’s native frame size is used.
- Returns:
A
Texturecontaining the decoded frame, orNoneif the provider does not support thumbnail generation or could not decode the asset at the requested time.
Providers should override this. The default implementation logs an informational message and returns
None.New in version 3.0.0.
- load()¶
Load the video from the current filename
- on_buffering(value)¶
Fired when
bufferingtransitions.value is the new buffering state (
TrueorFalse).New in version 3.0.0.
- property options¶
Get the provider-specific options dict that was passed to the provider at construction time. Read-only at the base class level; providers may mutate it during their lifetime.
New in version 3.0.0.
- pause()¶
Pause the video
New in version 1.4.0.
- play()¶
Play the video
- property position¶
Get/set the position in the video (in seconds)
- seek(percent, precise=True)¶
Move to position as percentage (strictly, a proportion from 0 - 1) of the duration
- property state¶
Get the video playing status
- stop()¶
Stop the video playing
- property texture¶
Get the video texture
- unload()¶
Unload the actual video
- property volume¶
Get/set the volume in the video (1.0 = 100%)