michael-mueller-git / Python-Funscript-Editor

Funscript Editor written in Python with an motion tracking add-on to partially automate the generation of funscripts
MIT License
52 stars 9 forks source link

MTFG crashes after I click OK button on settings popup #16

Closed geogan closed 6 months ago

geogan commented 2 years ago

Using latest OFS 2.0.0 and Python Funscript Generator 0.4.1

From funscript_editor.log

2022-08-22 13:10:29,174 - funscript_editor.api - INFO - Python Funscript Generator 0.4.1
2022-08-22 13:10:29,175 - funscript_editor.api - INFO - Startup Path: C:\Program Files\OpenFunscripter
2022-08-22 13:10:29,175 - funscript_editor.api - INFO - Args: video_file=xxx, start_time=879.0, end_time=35833.0, output_file=C:\Users\xxxx\AppData\Roaming\OFS\OFS2_data\extensions\Funscript Generator Windows/funscript_actions.json
2022-08-22 13:10:29,532 - funscript_editor.ui.funscript_generator_window - INFO - Set End Time to Frame Number 36
2022-08-22 13:10:29,532 - funscript_editor.ui.funscript_generator_window - INFO - Hyperparameter:{'min_frames': 90, 'user_reaction_time_in_milliseconds': 1000, 'signal': {'local_max_min_filter_len': 1, 'avg_sec_for_local_min_max_extraction': 2.0, 'distance_minimization_threshold': 16.0, 'high_second_derivative_points_threshold': 1.2, 'direction_change_filter_len': 3, 'additional_points_merge_time_threshold_in_ms': 60, 'additional_points_merge_distance_threshold': 8.0, 'min_evenly_intermediate_interframes': 2, 'additional_points_repetitions': 2}, 'scene_detector': {'min_scene_len_in_seconds': 3, 'scene_content_detector_threshold': 30.0, 'scene_threshold_detector_threshold': 12}, 'tracker': {'tracking_init_phase_in_sec': 6, 'tracking_plausibility_factor_x': 4.0, 'tracking_plausibility_factor_y': 2.5}}
2022-08-22 13:10:29,532 - funscript_editor.ui.funscript_generator_window - INFO - Config:{'use_zoom': False, 'zoom_factor': 4.0, 'max_playback_fps': 0, 'preview_scaling': 0.6, 'tracker': 'CSRT', 'notification_sound': 'off', 'scene_detector': 'CSV', 'raw_output': False, 'dark_theme': False, 'tracking_plausibility_check': False, 'ffmpeg_timeout_in_seconds': 15}
2022-08-22 13:10:35,100 - funscript_editor.ui.funscript_generator_window - INFO - settings: {'videoType': '2D Video with Filters', 'trackingMetrics': 'y', 'trackingMethod': 'Unsupervised one moving person', 'numberOfTracker': '1', 'points': 'Local Min Max', 'additionalPoints': 'None', 'processingSpeed': '0', 'topPointOffset': 10, 'bottomPointOffset': -10}
2022-08-22 13:10:35,264 - funscript_editor.ui.opencvui - INFO - Show ROI Menu
2022-08-22 13:10:35,264 - funscript_editor.algorithms.funscriptgenerator - CRITICAL - The program crashed due to a fatal error
Traceback (most recent call last):
  File "funscript_editor\algorithms\funscriptgenerator.py", line 945, in run
  File "funscript_editor\algorithms\funscriptgenerator.py", line 600, in tracking
  File "funscript_editor\ui\opencvui.py", line 743, in get_video_projection_config
  File "funscript_editor\data\ffmpegstream.py", line 155, in get_projection
ZeroDivisionError: float division by zero
2022-08-22 13:10:35,265 - funscript_editor.ui.funscript_generator_window - INFO - Save result to C:\Users\xxx\AppData\Roaming\OFS\OFS2_data\extensions\Funscript Generator Windows\funscript_actions.json
2022-08-22 13:10:35,265 - funscript_editor.ui.funscript_generator_window - ERROR - The program crashed due to a fatal error
2022-08-22 13:11:25,997 - funscript_editor.api - INFO - Python Funscript Generator 0.4.1
2022-08-22 13:11:25,997 - funscript_editor.api - INFO - Startup Path: C:\Program Files\OpenFunscripter
2022-08-22 13:11:25,997 - funscript_editor.api - INFO - Args: video_file=xxx, start_time=879.0, end_time=35833.0, output_file=C:\Users\xxx\AppData\Roaming\OFS\OFS2_data\extensions\Funscript Generator Windows/funscript_actions.json
2022-08-22 13:11:26,345 - funscript_editor.ui.funscript_generator_window - INFO - Set End Time to Frame Number 36
2022-08-22 13:11:26,345 - funscript_editor.ui.funscript_generator_window - INFO - Hyperparameter:{'min_frames': 90, 'user_reaction_time_in_milliseconds': 1000, 'signal': {'local_max_min_filter_len': 1, 'avg_sec_for_local_min_max_extraction': 2.0, 'distance_minimization_threshold': 16.0, 'high_second_derivative_points_threshold': 1.2, 'direction_change_filter_len': 3, 'additional_points_merge_time_threshold_in_ms': 60, 'additional_points_merge_distance_threshold': 8.0, 'min_evenly_intermediate_interframes': 2, 'additional_points_repetitions': 2}, 'scene_detector': {'min_scene_len_in_seconds': 3, 'scene_content_detector_threshold': 30.0, 'scene_threshold_detector_threshold': 12}, 'tracker': {'tracking_init_phase_in_sec': 6, 'tracking_plausibility_factor_x': 4.0, 'tracking_plausibility_factor_y': 2.5}}
2022-08-22 13:11:26,345 - funscript_editor.ui.funscript_generator_window - INFO - Config:{'use_zoom': False, 'zoom_factor': 4.0, 'max_playback_fps': 0, 'preview_scaling': 0.6, 'tracker': 'CSRT', 'notification_sound': 'off', 'scene_detector': 'CSV', 'raw_output': False, 'dark_theme': False, 'tracking_plausibility_check': False, 'ffmpeg_timeout_in_seconds': 15}
2022-08-22 13:11:33,406 - funscript_editor.ui.funscript_generator_window - INFO - settings: {'videoType': '2D Video with Filters', 'trackingMetrics': 'y', 'trackingMethod': 'Unsupervised one moving person', 'numberOfTracker': '1', 'points': 'Local Min Max', 'additionalPoints': 'None', 'processingSpeed': '0', 'topPointOffset': 10, 'bottomPointOffset': -10}
2022-08-22 13:11:33,581 - funscript_editor.ui.opencvui - INFO - Show ROI Menu
2022-08-22 13:11:33,581 - funscript_editor.algorithms.funscriptgenerator - CRITICAL - The program crashed due to a fatal error
Traceback (most recent call last):
  File "funscript_editor\algorithms\funscriptgenerator.py", line 945, in run
  File "funscript_editor\algorithms\funscriptgenerator.py", line 600, in tracking
  File "funscript_editor\ui\opencvui.py", line 743, in get_video_projection_config
  File "funscript_editor\data\ffmpegstream.py", line 155, in get_projection
ZeroDivisionError: float division by zero
2022-08-22 13:11:33,583 - funscript_editor.ui.funscript_generator_window - INFO - Save result to C:\Users\xxx\AppData\Roaming\OFS\OFS2_data\extensions\Funscript Generator Windows\funscript_actions.json
2022-08-22 13:11:33,583 - funscript_editor.ui.funscript_generator_window - ERROR - The program crashed due to a fatal error
2022-08-22 13:11:35,197 - funscript_editor.ui.funscript_generator_window - INFO - EXIT with Workaround
geogan commented 2 years ago

I found out this only happens with a particular unusual file format so maybe just a bug in FFMPEG to do with that file format.

General
Format                                   : Matroska
Format version                           : Version 4
Overall bit rate                         : 1 400 kb/s
Encoded date                             : UTC 2022-08-13 18:16:20
Writing application                      : mkvmerge v69.0.0 ('Day And Age') 64-bit
Writing library                          : libebml v1.4.2 + libmatroska v1.6.4 / Lavf59.23.100

Video
ID                                       : 1
Format                                   : AV1
Format/Info                              : AOMedia Video 1
Format profile                           : Main@L4.0
Codec ID                                 : V_AV1
Duration                                 : 2 min 38 s
Bit rate                                 : 1 368 kb/s
Width                                    : 1 280 pixels
Height                                   : 736 pixels
Display aspect ratio                     : 1.739
Frame rate mode                          : Constant
Frame rate                               : 60.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.024
Stream size                              : 25.9 MiB (98%)
Writing library                          : Lavc59.27.100 libsvtav1
Default                                  : No
Forced                                   : No
Color range                              : Limited

Audio
ID                                       : 2
Format                                   : Opus
Codec ID                                 : A_OPUS
Duration                                 : 2 min 39 s
Bit rate                                 : 28.3 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 50.001 FPS (882 SPF)
Compression mode                         : Lossy
Stream size                              : 549 KiB (2%)
Default                                  : Yes
Forced                                   : No
michael-mueller-git commented 2 years ago

thank you for the bug report. The problem is that ffmpeg was not able to extract the frame. As a result I had no data to process and the program crashed. As a first fix I added an error message so that the program should not crash anymore 0338e3ce68e4e. When I have time I will try to reproduce the problem. Maybe a ffmpeg parameter is missing to use the video format...

geogan commented 2 years ago

Great thanks. My workaround was to just re-encode the original video to a standard format which did not break FFMPEG.

geogan commented 2 years ago

Hello, I seem to be getting some other failure now... and no idea why... it was working earlier, then I changed a few options in first options window when MFTG runs and now it won't run at all, even when I changed options back to the way they were. Any ideas? EDIT: I restarted entire OpenFunScripter and error went away

2022-09-10 15:05:43,157 - funscript_editor.ui.funscript_generator_window - INFO - Set End Time to Frame Number -1
2022-09-10 15:05:43,158 - funscript_editor.ui.funscript_generator_window - INFO - Hyperparameter:{'min_frames': 90, 'user_reaction_time_in_milliseconds': 1000, 'signal': {'local_max_min_filter_len': 1, 'avg_sec_for_local_min_max_extraction': 2.0, 'distance_minimization_threshold': 16.0, 'high_second_derivative_points_threshold': 1.2, 'direction_change_filter_len': 3, 'additional_points_merge_time_threshold_in_ms': 60, 'additional_points_merge_distance_threshold': 8.0, 'min_evenly_intermediate_interframes': 2, 'additional_points_repetitions': 2}, 'scene_detector': {'min_scene_len_in_seconds': 3, 'scene_content_detector_threshold': 30.0, 'scene_threshold_detector_threshold': 12}, 'tracker': {'tracking_init_phase_in_sec': 6, 'tracking_plausibility_factor_x': 4.0, 'tracking_plausibility_factor_y': 2.5}}
2022-09-10 15:05:43,158 - funscript_editor.ui.funscript_generator_window - INFO - Config:{'use_zoom': False, 'zoom_factor': 4.0, 'max_playback_fps': 0, 'preview_scaling': 0.6, 'tracker': 'CSRT', 'notification_sound': 'off', 'scene_detector': 'CSV', 'raw_output': False, 'dark_theme': False, 'tracking_plausibility_check': False, 'ffmpeg_timeout_in_seconds': 15}
2022-09-10 15:05:50,410 - funscript_editor.ui.funscript_generator_window - INFO - settings: {'videoType': '2D Video with Filters', 'trackingMetrics': 'y', 'trackingMethod': 'Unsupervised one moving person', 'numberOfTracker': '1', 'points': 'Local Min Max', 'additionalPoints': 'Distance Minimization', 'processingSpeed': '0', 'topPointOffset': 10, 'bottomPointOffset': -10}
2022-09-10 15:05:51,230 - funscript_editor.ui.opencvui - INFO - Show ROI Menu
2022-09-10 15:05:52,546 - funscript_editor.data.ffmpegstream - INFO - FFmpeg Stream Watchdog started with 15 sec timeout
2022-09-10 15:05:52,546 - funscript_editor.data.ffmpegstream - INFO - Open FFmpeg Stream
2022-09-10 15:05:55,270 - funscript_editor.ui.opencvui - INFO - User Input: (465, 660, 37, 13, 484, 666)
2022-09-10 15:05:55,271 - funscript_editor.algorithms.videotracker - INFO - Start CSRT Tracker
2022-09-10 15:05:55,271 - funscript_editor.algorithms.scenedetect - INFO - Use Scene Detector from CSV File
2022-09-10 15:05:55,271 - funscript_editor.algorithms.scenedetect - INFO - Scenes CSV File not found
2022-09-10 15:05:55,296 - funscript_editor.algorithms.funscriptgenerator - INFO - Raw tracking data: 1 Tracking points for 0 seconds of the video
2022-09-10 15:05:55,296 - funscript_editor.algorithms.funscriptgenerator - INFO - 1.1 Tracking Lost
2022-09-10 15:05:55,296 - funscript_editor.algorithms.funscriptgenerator - INFO - Interpolate tracking boxes
2022-09-10 15:05:55,296 - funscript_editor.algorithms.funscriptgenerator - INFO - Use quadratic interpolation
2022-09-10 15:05:55,296 - funscript_editor.algorithms.funscriptgenerator - INFO - Calculate score for 1 Tracker(s)
2022-09-10 15:05:55,296 - funscript_editor.algorithms.funscriptgenerator - CRITICAL - The program crashed due to a fatal error
Traceback (most recent call last):
  File "funscript_editor\algorithms\funscriptgenerator.py", line 945, in run
  File "funscript_editor\algorithms\funscriptgenerator.py", line 764, in tracking
  File "funscript_editor\algorithms\funscriptgenerator.py", line 310, in calculate_score
ValueError: min() arg is an empty sequence
2022-09-10 15:05:55,297 - funscript_editor.data.ffmpegstream - INFO - Close FFmpeg Stream
2022-09-10 15:05:55,297 - funscript_editor.data.ffmpegstream - INFO - FFmpeg Stream Watchdog stoped
2022-09-10 15:05:55,327 - funscript_editor.ui.funscript_generator_window - INFO - Save result to C:\Users\xxx\AppData\Roaming\OFS\OFS2_data\extensions\Funscript Generator Windows\funscript_actions.json
2022-09-10 15:05:55,328 - funscript_editor.ui.funscript_generator_window - ERROR - The program crashed due to a fatal error
2022-09-10 15:05:56,767 - funscript_editor.ui.funscript_generator_window - INFO - EXIT with Workaround
michael-mueller-git commented 6 months ago

fix crash due to empty sequence is now available in newer versions and this error should not longer occur. I also fixed an error where the program crashes when it is unable to decode the video #24 .

Please reopen issue if error still exists.

geogan commented 6 months ago

Thanks, I am still having strange random crashing of entire program but not related to this problem. (load existing project/video - it appears, finishes loading, then entire program crashes a few seconds later maybe 50% of time.)

michael-mueller-git commented 6 months ago

Thanks for your feedback. Unfortunately, i don't get much feedback from others about what doesn't work or causes problems. In Addition i don't use my program that often and therefor may not aware of all problems that exists.

If you program crash generates an traceback output in the logfile (as with your previously posted log). It would be helpful if you could just post it here or in a new issue. Then I can perhaps find out what the problem might be...