PySceneDetect icon indicating copy to clipboard operation
PySceneDetect copied to clipboard

Inconsistent error handling when start time exceeds video length

Open Breakthrough opened this issue 2 years ago • 0 comments

Description:

When using different backends with the CLI, setting start time to be beyond the end of the video will result in different behaviour. This should be made consistent if possible, otherwise the differences should be documented. Summary of differences:

  • OpenCV: Incorrect error message.
  • PyAV: Processes last frame.
  • MoviePy: Inconsistent error message due to wrong logger used when handling SeekError

Output:

Command: scenedetect -i goldeneye.mp4 time -s 10000

OpenCV:

[PySceneDetect] PySceneDetect 0.6.2
[PySceneDetect] Downscale factor set to 5, effective resolution: 256 x 108
[PySceneDetect] Detecting scenes...
  Detected: 0 | Progress: : 0frames [00:00, ?frames/s]
[PySceneDetect] Failed to read any frames from video file. This could be caused by the video having multiple audio tracks. If so, try installing the PyAV backend:
      pip install av
Or remove the audio tracks by running either:
      ffmpeg -i input.mp4 -c copy -an output.mp4
      mkvmerge -o output.mkv input.mp4
For details, see https://scenedetect.com/faq/

PyAV:

[PySceneDetect] PySceneDetect 0.6.2
[PySceneDetect] Downscale factor set to 5, effective resolution: 256 x 108
[PySceneDetect] Detecting scenes...
  Detected: 0 | Progress: : 0frames [00:00, ?frames/s]
[PySceneDetect] Processed 0 frames in 0.1 seconds (average 0.00 FPS).
[PySceneDetect] Detected 1 scenes, average shot length 0.0 seconds.
[PySceneDetect] Scene List:
-----------------------------------------------------------------------
 | Scene # | Start Frame |  Start Time  |  End Frame  |   End Time   |
-----------------------------------------------------------------------
 |      1  |        1980 | 00:01:22.541 |        1980 | 00:01:22.582 |
-----------------------------------------------------------------------

MoviePy:

[PySceneDetect] PySceneDetect 0.6.2
CRITICAL:root:Failed to seek to 00:06:57.042 / frame 9999: Target frame is beyond end of video!

Action Items

  • [ ] Correct logger used to report seek failures
  • [ ] Ensure all backends either throw a SeekError when attempting to seek() past EOF or that they all gracefully stop at "one-past" the last frame
  • [ ] Ensure incorrect error messaging for #179 is not displayed when no frames have been processed

Breakthrough avatar Feb 19 '24 23:02 Breakthrough