Skip to content

Latest commit

 

History

History
47 lines (36 loc) · 4.81 KB

Documentation.md

File metadata and controls

47 lines (36 loc) · 4.81 KB

TkVideoPlayer:

TkVideoPlayer inherits from tk.Label and display's the image on the label.

Below are the methods of this library.

Methods Parameters Description
__init__
  • scaled(bool)
  • consistant_frame_rate(bool)
  • keep_aspect(bool)=False
  • audio(bool)=False
  • The scaled parameter scales the video to the label size.
  • The consistant_frame_rate parameter adds an appropriate time delay to keep the framerate consistant.
  • keep_aspect keeps aspect ratio when resizing. (note: It will not increase the size)
  • audio enables audio in clip (experimental)
  • set_scaled
  • scaled(bool)
  • keep_aspect(bool)=False
  • scales the video to the label size.
    load file_path(str) starts loading the video file in a thread.
    set_size
  • size(Tuple[int, int])
  • keep_aspect(bool)=False
  • sets the size of the video frame, setting this will set scaled to False.
    current_duration - return the current video duration in seconds.
    current_frame_number - get the current number of the frame.
    video_info - returns a dictionary containing name, framerate, framesize, duration, total frames and codec of the video.
    play - Plays the video.
    pause - Pauses the video.
    is_paused - returns if the video is currently paused.
    is_stopped - returns if the video is currently stopped.
    stop - stops playing the file, closes the file.
    seek
  • sec(int)
  • any_frame(bool)=False
  • pause(bool)=False
  • moves to specific time stamp. (provide time stamp in seconds only)
  • any_frame: seek to any nearest keyframe if possible.
  • The pause parameter pauses the video after seeking to the given timestamp.
  • seek_frame
  • frame(int)
  • delay(float)=False
  • pause(bool)=True
  • moves to the specific frame number.
  • delay (0-1): add a slight delay while seeking for optimization
  • The pause parameter pauses the video after seeking to the given frame.
  • keep_aspect keep_aspect(bool) keeps aspect ratio when resizing.
    metadata - returns meta information of the video if available in the form of dictionary.
    set_resampling_method method(int) The resampling method while resizing can be set as NEAREST, this can affect how its resampled when image is displayed, refer PIL documentation to read more. (note: this can also affect the framerate of the video)
    current_img - get the current frame image.

    Virtual events:

    Virtual event Description
    <<Loaded>> This event is generated when the video file is opened.
    <<Duration>> This event is generated when the video duration is found.
    <<SecondChanged>> This event is generated whenever a second in the video passes (calculated using frame_number%frame_rate==0).
    <<FrameChanged>> This event is generated whenever there is a new frame available.
    <<Ended>> This event is generated only when the video has ended.

    Note:

    If you would like to draw on the video etc. Copy/fork the repo and instead of inheriting from Label inherit from Canvas.

    And add image_id = self.create_image() and then use the image_id to update the image.