Skip to content

Commit f0c94cd

Browse files
authored
read_video: accept BytesIO on pyav backend (#8442)
1 parent 45e053b commit f0c94cd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

torchvision/io/video.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def read_video(
244244
Reads a video from a file, returning both the video frames and the audio frames
245245
246246
Args:
247-
filename (str): path to the video file
247+
filename (str): path to the video file. If using the pyav backend, this can be whatever ``av.open`` accepts.
248248
start_pts (int if pts_unit = 'pts', float / Fraction if pts_unit = 'sec', optional):
249249
The start presentation time of the video
250250
end_pts (int if pts_unit = 'pts', float / Fraction if pts_unit = 'sec', optional):
@@ -267,10 +267,9 @@ def read_video(
267267

268268
from torchvision import get_video_backend
269269

270-
if not os.path.exists(filename):
271-
raise RuntimeError(f"File not found: {filename}")
272-
273270
if get_video_backend() != "pyav":
271+
if not os.path.exists(filename):
272+
raise RuntimeError(f"File not found: {filename}")
274273
vframes, aframes, info = _video_opt._read_video(filename, start_pts, end_pts, pts_unit)
275274
else:
276275
_check_av_available()

0 commit comments

Comments
 (0)