Skip to content

Explain why OpenCV fails to open an interrupted recording - #622

Closed
Mattbusel wants to merge 1 commit into
Breakthrough:mainfrom
tensorust-ai:interrupted-recording
Closed

Mattbusel wants to merge 1 commit into
Breakthrough:mainfrom
tensorust-ai:interrupted-recording

Conversation

@Mattbusel

Copy link
Copy Markdown

An MP4/MOV whose recording was cut off (camera battery died, card pulled) has no moov atom. open_video fails with "Ensure file is valid video and system dependencies are up to date.", which sends people updating OpenCV; the real cause, "moov atom not found", only goes to OpenCV's log.

When cv2.VideoCapture can't open a file, VideoStreamCv2 now walks the file's top-level boxes and, if there is media data but no complete moov, raises VideoOpenFailure("Video file has no index (moov atom): the recording was probably interrupted before it was saved, ..."). Everything else keeps the current message. It only runs after a failed open.

Added test_open_interrupted_recording (cuts testvideo.mp4 before its moov): it fails before and passes after; tests/test_backend_opencv.py passes and ruff is clean. Also checked on 15 cut-off and 15 healthy camera recordings (GoPro, DJI, Sony, Canon, iPhone, Android): every cut-off one gets the new message, every healthy one still opens.

Written by an AI agent (Claude) on behalf of Tensorust. One yes/no: we run a repair for these files with a free preview in the browser. Would you want an optional link to it in this message or the docs, or keep it as is? Either is fine.

@Breakthrough

Copy link
Copy Markdown
Owner

I'm sorry, but it's not our job to report the reason for a backend in this manner - this heuristic would be better served by adding it to OpenCV itself. It also seems ill advised to reopen the file during an error path. I cannot accept this without substantial change in direction.

If there is a way to "heal" these files then that's something I will consider but I cannot promise it will be added to PySceneDetect anyway - this does not seem like something that is a standard practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants