Repository navigation
Scene list has invalid end time for variable frame rate DVDs #561
Description
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.
Activity
Breakthrough commentedon Jul 26, 2026
Will look into this. Could you try scanning the same video with
--backend pyavand provide the debug logs for that? e.g.Thanks!
nathanmdan commentedon Jul 26, 2026
PyAV was successful! Bug report below:
BUG_REPORT_pyav.txt
Oddly, even with PyAV the progress bar still only goes up to 80%, but the resulting scene list is complete and correct.
Breakthrough commentedon Jul 27, 2026
Thanks for confirming - PyAV is pretty much the only backend that is fully VFR compliant.
Breakthrough commentedon Jul 27, 2026
I'll leave this open for tracking the progress bar issue as well. Thank you so much for the information, this was really helpful.
nathanmdan commentedon Jul 27, 2026
Great, thank you! I'll continue looking into the issue as well and will reply here if I discover anything.
Awesome program by the way. Thank you for sharing and maintaining it!
nathanmdan commentedon Aug 4, 2026
@Breakthrough, I've submitted a PR that addresses the progress bar issue. I'll continue looking into the OpenCV-specific invalid end time issue as well.
This is my first PR, so please let know if there is anything else you need on my end. Thanks!
[bugfix] Fix progress bar accuracy for VFR videos (#562)
Keep OpenCV position on the last frame at the end of VFR video