Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
213c36b
New features and improvements
Akascape Apr 2, 2023
9dd029c
Update Documentation.md
Akascape Apr 2, 2023
290c12a
Create advanced_example.py
Akascape Apr 2, 2023
84c476e
Update Readme.md
Akascape Apr 2, 2023
a3e04ad
Update Readme.md
Akascape Apr 2, 2023
32eb474
Update Readme.md
Akascape Apr 2, 2023
a06d68e
Delete dist directory
Akascape Jan 20, 2024
7a3c035
Delete tkvideoplayer.egg-info directory
Akascape Jan 20, 2024
607ea11
Delete build/lib/tkVideoPlayer directory
Akascape Jan 20, 2024
1b5c27c
Update LICENSE
Akascape Jan 20, 2024
fdbdac8
Delete setup.py
Akascape Jan 20, 2024
9d0193c
Update Readme.md
Akascape Jan 20, 2024
8f9e636
Update Readme.md
Akascape Jan 20, 2024
ea3d598
Update Readme.md
Akascape Jan 20, 2024
8836cf0
Update Readme.md
Akascape Jan 20, 2024
713c4e6
Update Readme.md
Akascape Jan 20, 2024
bec0591
Add files via upload
Akascape Jan 20, 2024
a0b68cb
Update Readme.md
Akascape Jan 20, 2024
2ac366b
Delete videoplayer_screenshot.png
Akascape Jan 25, 2024
2835391
Delete sample_media_player.png
Akascape Jan 25, 2024
768e07c
Update requirements.txt
Akascape Jan 25, 2024
58dc422
Added audio # beta stage
Akascape Mar 3, 2024
1fabbbf
Update requirements.txt
Akascape Mar 3, 2024
f8a92a1
Update Documentation.md
Akascape Mar 3, 2024
a7e1bed
Update Documentation.md
Akascape Mar 3, 2024
9549dff
Update Readme.md
Akascape Mar 3, 2024
d9aa07e
Update Readme.md
Akascape Mar 3, 2024
909a44a
Fixed audio
Akascape Mar 5, 2024
0267fae
Fixed Audio
Akascape Mar 5, 2024
fef8f13
Update Readme.md
Akascape Mar 5, 2024
ee48af2
Added audio
Akascape Mar 5, 2024
01db7b9
Update Readme.md
Akascape Mar 5, 2024
3d2910f
Update Readme.md
Akascape Mar 5, 2024
0b7aea2
Added audio + fixed memory leakage
Akascape Mar 5, 2024
709f859
Added audio and fixed memory leakage
Akascape Mar 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions Documentation.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
# TkVideoPlayer:

TkVideoPlayer inherits from `tk.Label` and display's the image on the label.
**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)=True, keep_aspect(bool)=False | The scale parameter scales the video to the label size. The consistant_frame_rate parameter skips frames to keep the framerate consistant and keep_aspect keeps aspect ratio when resizing(note: It will not increase the size) |
| set_scaled | scaled(bool), keep_aspect(bool)=False | scales the video to the label size. |
| load | file_path(str) | starts loading the video 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 video duration in seconds. |
| video_info | - | returns dictionary containing framerate, framesize, duration.|
| play | - | Plays the video. |
| pause | - | Pauses the video |
| is_paused | - | returns if the video is currently paused.
| stop | - | stops playing the file, closes the file. |
| seek | sec(int) | moves to specific time stamp. provide time stamp in seconds
| 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) | By default the resampling method while resizing is NEAREST, changing this can affect how its resampled when image is resized, refer PIL documentation to read more (note: this can also affect the framerate of the video)|
| **\_\_init\_\_** | <li>scaled(bool)</li> <li>consistant_frame_rate(bool)</li> <li>keep_aspect(bool)=False</li> <li>audio(bool)=False</li> | <li>The _scaled_ parameter scales the video to the label size.</li> <li>The _consistant_frame_rate_ parameter adds an appropriate time delay to keep the framerate consistant.</li> <li>_keep_aspect_ keeps aspect ratio when resizing. (note: It will not increase the size) </li> <li>_audio_ enables audio in clip (experimental) </li>|
| set_scaled | <li>scaled(bool)</li> <li>keep_aspect(bool)=False</li> | scales the video to the label size. |
| **load** | file_path(str) | starts loading the video file in a thread. |
| set_size | <li>size(Tuple[int, int])</li> <li>keep_aspect(bool)=False</li> | 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** | <li>sec(int)</li> <li>any_frame(bool)=False</li> <li>pause(bool)=False</li> | <li>moves to specific time stamp. (provide time stamp in seconds only) </li> <li> any_frame: seek to any nearest keyframe if possible.</li> <li>The _pause_ parameter pauses the video after seeking to the given timestamp.</li> |
| **seek_frame** | <li>frame(int)</li> <li>delay(float)=False</li> <li>pause(bool)=True</li> | <li>moves to the specific frame number.</li> <li>delay (0-1): add a slight delay while seeking for optimization</li> <li>The _pause_ parameter pauses the video after seeking to the given frame.</li>
| 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. |
| \<\<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). |
| \<\<FrameGenerated\>\> | This event is generated whenever there is a new frame available. (internal use, don't use this unless you want to). |
| \<\<FrameChanged\>\> | This event is generated whenever there is a new frame available. |
| \<\<Ended\>\> | This event is generated only when the video has ended. |

<sub>

note:
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 use `image_id = self.create_image()` use the image_id to update the image.

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

</sub>

22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,25 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

MIT License

Copyright (c) 2024 Akascape

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
40 changes: 22 additions & 18 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# TkVideoplayer

This is a simple library to play video files in tkinter. This library also provides the ability to play, pause,
skip and seek to specific timestamps.

#### Example:
This is a simple library to **play video** files in tkinter. This library also provides the ability to play, pause,
skip and seek to specific timestamps of the video. (Audio included)

### Installation
This is a modified version of tkVideoPlayer by PauleDemon. Download the folder tkVideoPlayer of this fork.

Functionalities:
- load(path) : to load a video file
- stop() : stops the video
- play() : plays the video
- video_info() : return video info like framerate(fps), durartion, frame size, total frames, codec and name of the video
- current_frame_number() : returns the frame number of current location
- current_img() : return the PIL image of current frame
- seek(sec, pause) : seek to any timestamp, use pause=True to pause after seeking
- seek_frame(frame, pause) : seeks accurately to any frame number, use pause=True to pause after seeking
- mute()/unmute() : enable audio in clip (currently in beta stage)
#### Simple Usage:
```python
import tkinter as tk
from tkVideoPlayer import TkinterVideo
Expand All @@ -18,20 +31,11 @@ videoplayer.play() # play the video

root.mainloop()
```
## If you are facing issues while playing some videos, turn off the audio.

read the documentation [here](https://github.com/PaulleDemon/tkVideoPlayer/blob/master/Documentation.md)

> Please immediately upgrade to the latest version if you are using version 1.3 or below
#### Sample video player made using tkVideoPlayer:
![Sample player](https://github.com/PaulleDemon/tkVideoPlayer/blob/master/videoplayer_screenshot.png?raw=True)

This example source code can be found [here](https://github.com/PaulleDemon/tkVideoPlayer/blob/master/examples/sample_player.py)


**Other libraries you might be interested in:**

* [tkstylesheet](https://pypi.org/project/tkstylesheet/) - Helps you style your tkinter application using stylesheets.
### read the documentation [here](https://github.com/Akascape/tkVideoPlayer/blob/master/Documentation.md)

* [tkTimePicker](https://pypi.org/project/tkTimePicker/) - An easy-to-use timepicker.
### Sample video players made using tkVideoPlayer:
<img src="https://user-images.githubusercontent.com/89206401/229363046-36ebcffd-36d2-4c7f-98ce-4aa6b402e9e0.png" width=550>

* [PyCollision](https://pypi.org/project/PyCollision/) - Helps you draw hitboxes for 2d games.
https://user-images.githubusercontent.com/89206401/228515652-abe137d0-6823-4c56-ba5c-8eb8292e0182.mp4
1 change: 0 additions & 1 deletion build/lib/tkVideoPlayer/__init__.py

This file was deleted.

Loading