Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_video: accept BytesIO on pyav backend #8442

Merged
merged 5 commits into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions torchvision/io/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def read_video(
Reads a video from a file, returning both the video frames and the audio frames

Args:
filename (str): path to the video file
filename (str): path to the video file. If using the pyav backend, this can be whatever ``av.open`` accepts.
start_pts (int if pts_unit = 'pts', float / Fraction if pts_unit = 'sec', optional):
The start presentation time of the video
end_pts (int if pts_unit = 'pts', float / Fraction if pts_unit = 'sec', optional):
Expand All @@ -267,10 +267,9 @@ def read_video(

from torchvision import get_video_backend

if not os.path.exists(filename):
raise RuntimeError(f"File not found: {filename}")

if get_video_backend() != "pyav":
if not os.path.exists(filename):
raise RuntimeError(f"File not found: {filename}")
vframes, aframes, info = _video_opt._read_video(filename, start_pts, end_pts, pts_unit)
else:
_check_av_available()
Expand Down
Loading