Why can't VideoCapture load video files with colons if not prefixed with "./"

I used ISO timestamps for filenames.
Strangely, I can load those files ONLY if the filename is prefixed “./”.
Files containing “:” and not prefixed “./” are not successfully opened. Absolute paths also fail. Why? I assume it’s a bug.

openv 4.3.0 / ubuntu 18.

import cv2

for filename in [
      "2022-01-20T00:55:51.541238+00:00.mp4",  # isOpened=False
    "./2022-01-20T00:55:51.541238+00:00.mp4",  # isOpened=True
      "2022.mp4",  # True
    "./2022.mp4",  # True
      "2022+00:00.mp4",  # False
    "./2022+00:00.mp4",  # True
      "2022:00.mp4",  # False
    "./2022:00.mp4",  # True
      "2022+00.mp4",  # True
    "./2022+00.mp4"  # True
]:
    cap = cv2.VideoCapture(filename)
    print(f"Opened: [{cap.isOpened()}] {filename}")

---- Update:
Curiously, it doesn’t result from all uses of colons. Here’s the output with another set of filenames.

Opened: [False] 2022-01-20T00:55:51.541238+00:00.mp4
Opened: [True] ./2022-01-20T00:55:51.541238+00:00.mp4
Opened: [False] 2022:00.mp4
Opened: [True] 2022+00.mp4
Opened: [True] ./2022:00.mp4
Opened: [True] ./2022+00.mp4

might be the backends fighting over who can interpret the string. speculation.

nail it down, pass apiPreference=CAP_FFMPEG or something. if that doesn’t make a difference, try those paths given to a plain ffmpeg on the command line.

1 Like

It is really not a bug. Colon is not allowed in filenames on practically all operating systems, and you have just demonstrated what can happen with.

Programs may well interpret it as a delimiter character for a disc drive, a protocol or whatever.

Hmmm… colons are allowed on all flavors of Linux.
But if there’s really a policy to disallow non-portable filenames, perhaps openCV could raise an exception?
The ‘sometimes works, sometimes fails’ behavior certainly smells like a bug.

colons are used as separators in environment variables in all flavors of linux

colons are also used by ffmpeg for various separation purposes, even in input “file names”

maybe opencv does some parsing here, maybe not. you’d wanna set OPENCV_VIDEOIO_DEBUG and hope it’s logging enough useful things