Skip to content

Scene list has invalid end time for variable frame rate DVDs #561

Description

@nathanmdan

Description:

When generating a scene list from a variable frame rate DVD source (MPEG2 stream in MKV container), the end time of the last shot in the list is earlier than its start time. This results in an error when using split-video with the --mkvmerge option: Error: Invalid end time for '--split' in [...]. The end time must be bigger than the start time., followed by Error splitting video (mkvmerge returned 2)., and no files are written.

Interestingly, the invalid end time is the same as the last position of the detection progress bar, which stopped updating at 80% even though it successfully detected 100% of the cuts in the video. This seems to suggest a connection.

Tested with 2 separate MKV-wrapped MPEG2 video files and with different detection methods. All produce the same invalid end time.

Please let me know if any further info would be helpful. I am also interested in looking further into this myself and can follow up if I find the source of the issue.

Commands:

scenedetect -i .\dvd_ntsc_vfr.mkv list-scenes -n

scenedetect -i .\dvd_ntsc_vfr.mkv list-scenes -n split-video --mkvmerge

Output:

[PySceneDetect] Detecting scenes...
  Detected: 281 | Progress:  80%|█████████████████████████████████▋        | 35840/44745 [00:31<00:07, 1133.57frames/s]
[PySceneDetect] Processed 35840 frames in 31.6 seconds (average 1133.51 FPS).
[PySceneDetect] Detected 282 scenes, average shot length 5.3 seconds.
[PySceneDetect] Scene List:
-----------------------------------------------------------------------
 | Scene # | Start Frame |  Start Time  |  End Frame  |   End Time   |
-----------------------------------------------------------------------
 |      1  |           1 | 00:00:00.000 |          37 | 00:00:01.218 |
 |      2  |          38 | 00:00:01.218 |         751 | 00:00:25.075 |
 
 [...]

 |    280  |       44533 | 00:24:45.884 |       44628 | 00:24:49.104 |
 |    281  |       44629 | 00:24:49.104 |       44712 | 00:24:51.890 |
 |    282  |       44713 | 00:24:51.890 |       35840 | 00:19:55.861 |
-----------------------------------------------------------------------
[PySceneDetect] Comma-separated timecode list:
  00:00:01.218,00:00:25.075, [...] ,00:24:49.104,00:24:51.890
[PySceneDetect] Splitting video with mkvmerge, path template: dvd_ntsc_vfr-Scene.mkv
mkvmerge v100.0 ('Do Hot Girls Like Chords') 64-bit
Error: Invalid end time for '--split' in '--split parts:00:00:00.000-00:00:01.218, [...] , 00:24:51.890-00:19:55.861' (current part: 00:24:51.890-00:19:55.861). The end time must be bigger than the start time.
[PySceneDetect] Average processing speed 915537.03 frames/sec.
[PySceneDetect] Error splitting video (mkvmerge returned 2).
[PySceneDetect] Video splitting completed, scenes written to disk.

Environment:

System Info
------------------------------------------------------------
OS                     Windows-11-10.0.26200-SP0
Python                 CPython 3.13.9
Architecture           64bit + WindowsPE

Packages
------------------------------------------------------------
scenedetect            0.7.1
scenedetect-core       Not Installed
scenedetect-headless   Not Installed
av                     18.0.0
click                  8.4.2
opencv-python          Not Installed
opencv-python-headless 5.0.0
imageio                2.37.4
imageio-ffmpeg         0.6.0
moviepy                2.2.1
numpy                  2.5.1
platformdirs           4.11.0
tqdm                   4.69.0

Tools
------------------------------------------------------------
ffmpeg                 8.1.2-full_build-www.gyan.dev
mkvmerge               v100.0 ('Do Hot Girls Like Chords') 64-bit

Media/Files:

BUG_REPORT.txt and MediaInfo metadata files attached below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions