Skip to content

Vidio OpenCVReader failing on some videos #192

@jonahpearl

Description

@jonahpearl

This issue may be fairly specific to Tim's 6cam rig setup in our lab but here it is anyways — the OpenCVReader from vidio can't figure out how many frames those videos have, and that causes a weird failure in the grid movie code.

MRE:

from vidio.read import OpenCVReader

p = # path to video from tim's 6cam rig 
reader = OpenCVReader(p);
print(reader.nframes)  # some large negative integer
frame = reader.read(0)  # error due to this line in vidio: https://github.com/jbohnslav/vidio/blob/df2be96f63a06fa009d087fa81982fb8e2d27ec4/vidio/read.py#L39

# manual fix that should work unless you try to iterate through the reader object
reader.nframes = 1e6  # or some other large number
frame = reader.read(0)  # works

Suggested fix: use check_video_paths to return the open and, if needed, manually fixed OpenCVReader objects. So something like

readers = {}
for path in video_paths:
  reader = OpenCVReader(path)
  try:
      reader[0]
  except ValueError:
      reader.nframes = 1e7
  except:
      unreadable_videos.append(path)
      continue
  readers[path] = reader

But also there's a chance this introduces weird bugs into the video reading code, so this should probably just be a local fix for anyone in our lab who needs it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions