Conversation
Documentation.md
Outdated
| | 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>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> | |
Readme.md
Outdated
|
|
||
| This example source code can be found [here](https://github.com/PaulleDemon/tkVideoPlayer/blob/master/examples/sample_player.py) | ||
| ### Sample video players made using tkVideoPlayer: | ||
| <img src="https://user-images.githubusercontent.com/89206401/229363046-36ebcffd-36d2-4c7f-98ce-4aa6b402e9e0.png" width=550> <img src="https://github.com/PaulleDemon/tkVideoPlayer/blob/master/videoplayer_screenshot.png?raw=True" width=550> |
| @@ -0,0 +1,89 @@ | |||
| """ | |||
| Author: Akascape | |||
| This is an advanced example of tkvideoplayer with frame-seeking | |||
|
|
||
| logging.getLogger('libav').setLevel(logging.ERROR) # removes warning: deprecated pixel format used | ||
|
|
||
| logging.getLogger('libav').setLevel(logging.CRITICAL) # removes warning: deprecated pixel format used |
| "framesize": (0, 0) # tuple containing frame height and width of the video | ||
|
|
||
| "framesize": (0, 0), # tuple containing frame height and width of the video | ||
| "frames": 0, # total frames of the video |
There was a problem hiding this comment.
Added 3 more video info: name, total frames, codec
|
|
||
| def _display_frame(self, event): | ||
| """ displays the frame on the label """ | ||
| self.event_generate("<<FrameChanged>>") |
There was a problem hiding this comment.
Added a new frame changed event
| self._seek_sec = 0 | ||
|
|
||
|
|
||
| if self._seek_pause: |
There was a problem hiding this comment.
new parameter pause can be used to pause the video after seeking
| self.play() | ||
| self.after(50, self.pause) | ||
|
|
||
| if self._seek_frame: # seek to a specific frame |
There was a problem hiding this comment.
New seek frame method for seeking any particular frame
| self.path = path | ||
|
|
||
| self._load_thread = None | ||
| self._container = None |
There was a problem hiding this comment.
we should reload the container so that it works even after any pyav crash.
|
|
||
| def is_stopped(self): | ||
| """ returns if the video is stopped """ | ||
| return self._stop |
There was a problem hiding this comment.
stop event can be useful while looping or opening a new video
| self._seek_sec = sec | ||
|
No newline at end of file |
||
| self._seek_sec = sec | ||
| self._any_frame = any_frame |
There was a problem hiding this comment.
any_frame can be useful while seeking some corrupted videos
| self._seek_frame = True | ||
| self._frame = frame | ||
| self._seek_pause = pause | ||
| self._delay = delay if int(delay)<1 else 1.0 |
There was a problem hiding this comment.
add a slight delay while seeking a frame, so that cpu usage can be minimized.
|
Have you also taken care of audio? As far as I'm aware, the base library doesn't play audio as of yet. |
|
@vguttmann The problem is with syncing audio video together without any delay. Issue already raised here : #2 But I guess we can add it, maybe in future I will try... |
|
@vguttmann I tried adding audio, but it doesn't sync properly with all video. https://github.com/Akascape/tkVideoPlayer |
|
@Akascape have you tried using multiple threads? like a separate thread for Audio. Check this StackOverflow answer I wrote a while back. Also, is this branch up-to-date with the current release? I am pretty busy these days so I may not be able to contribute. If you make it work let me know, I'll look into it and merge. |
|
@PaulleDemon I am not using a different thread, I used I have asked the question here: https://stackoverflow.com/questions/78095616/syncing-audio-video-in-pyav-decoding But someone said that it is not necessary for a file to have the frames in presentation order. We must sync them separately. I also tried adding another thread for The audio frame decoding is realtime but video frame is not. Maybe we should find a way to display the video frames according to their pts to avoid sync delays. So for now, it works well with some video files. I am still working on this. |
|
@PaulleDemon Fixed the audio issue, I used the buffering method which just store (10-30) frames per loop and show them according to audio pts, which is also realtime. but don't know if there will be any issue with files having variable frame rate |
|
@Akascape Good to know you figured it out. I would still require some more people to test it out. Can you create a new pull request titled "added sound" or something so people can come test it out? Also, I see one commit stating fixed memory leak, what memory leak is that about? Is it upgrading to pyav 11 or something? |
|
@PaulleDemon I found that there is a memory leak if the stream is not closed before loading a new file. It's simple, just add |
Use this version if you want any of the following feature: