From bf75af9b189fc353e6d4e80c8bec21b1890f38f7 Mon Sep 17 00:00:00 2001 From: Bruno Korbar Date: Fri, 4 Jun 2021 05:01:00 -0500 Subject: [PATCH] Add warning for files with corrupt containers --- torchvision/io/video.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/torchvision/io/video.py b/torchvision/io/video.py index faa2f236fa3..b45e6da9f44 100644 --- a/torchvision/io/video.py +++ b/torchvision/io/video.py @@ -391,9 +391,9 @@ def read_video_timestamps(filename: str, pts_unit: str = "pts") -> Tuple[List[in except av.AVError: warnings.warn(f"Failed decoding frames for file {filename}") video_fps = float(video_stream.average_rate) - except av.AVError: - # TODO add a warning - pass + except av.AVError as e: + msg = f"Failed to open container for {filename}; Caught error: {e}" + warnings.warn(msg, RuntimeWarning) pts.sort()