PaulleDemon / tkVideoPlayer

Video player for tkinter.
MIT License
79 stars 25 forks source link

What to do if pyav crashes? #9

Closed Akascape closed 2 years ago

Akascape commented 2 years ago

@PaulleDemon TkvideoPlayer works fine with normal video but when a damaged file or non-video file is loaded then the pyav crashes and tkvideoplayer options also freezes and we have to restart the program.

Is there any way to reload or stop the pyav process in that case?

Secondly, I am also facing a playback speed issue with some raw videos (with variable frame rates) , I tried changing vid_player.set_resampling_method(1) and consistant_frame_rate=True but still the playback speed is very high with those videos.

How can I fix this?

PaulleDemon commented 2 years ago

@Akascape Sorry for the late reply, I didn't get notified of this issue, Is there any traceback? If there is then just catch the error using the try-except clause and inform the user that the file is corrupted.

As for the frame rate issue. Can you try uncommenting this line? https://github.com/PaulleDemon/tkVideoPlayer/blob/dcb81a8d1180a0e489d49414fcb7519a004706b3/tkVideoPlayer/tkvideoplayer.py#L179

Also the self._video_meta should be _video_info. Try and let me know.

Akascape commented 2 years ago

@PaulleDemon Its working with those but normal videos are now slowed. Btw I have fixed the crash error by limiting the file type.

PaulleDemon commented 2 years ago

@Akascape I'll look into this later, let me know if you have any ideas. Thanks

Akascape commented 2 years ago

@PaulleDemon I have built my app and everything is working fine but the crash is sometimes critical when a corrupted video is played. I am getting this traceback:

Exception in thread Thread-4 (_load):
Traceback (most recent call last):
  File "Python\lib\threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "Python\lib\threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "Python\lib\site-packages\tkVideoPlayer\tkvideoplayer.py", line 106, in _load
    with av.open(path) as self._container:
  File "av\container\core.pyx", line 401, in av.container.core.open
  File "av\container\core.pyx", line 272, in av.container.core.Container.__cinit__
  File "av\container\core.pyx", line 292, in av.container.core.Container.err_check
  File "av\error.pyx", line 336, in av.error.err_check
av.error.InvalidDataError: [Errno 1094995529] Invalid data found when processing input: 'corrupted_video.mp4'; 
last error log: [mov,mp4,m4a,3gp,3g2,mj2] moov atom not found

After this error, the video player freezes and stops working. Even a stable video is not playable without a restart. What to do in that case?

PaulleDemon commented 2 years ago

@Akascape Have you tried try-except block? Maybe just try catching the error and stop the video from playing.

Akascape commented 2 years ago

@PaulleDemon I used the try-except method like this:

def play_pause():
    """ pauses and plays """
    try:
        if vid_player.is_paused():
            vid_player.play()
            play_pause_btn["text"] = "Pause"
        else:
            vid_player.pause()
            play_pause_btn["text"] = "Play"
    except:
        pass

I tried the try-except method in every block but still getting that error if I load that video directly. Actually the case is rare and only happens with conversion failed videos(with no data). But as my program is about data corruption and glitch art so sometimes it may create those type of videos, and I want to block those from interrupting the program. What can I do?

PaulleDemon commented 2 years ago

@Akascape sorry for the late reply, I am not being notified of the conversations on time. Can you check out this post on SO: https://stackoverflow.com/questions/11523797/how-to-add-a-moov-atom-in-a-mp4-video-file

Akascape commented 2 years ago

I tried -movflags faststart but its not working. I think I have to try different conversion settings and also have to improve my other core files. Thanks for your help... @PaulleDemon

PaulleDemon commented 2 years ago

@Akascape Ok, then can I close the issue? since it's not directly related to the library.