-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Allow passing a file-like object to torchvision.io.video.read_video #8438
Comments
Hi @voegtlel , thank you for the feature request. Can you detail exactly what you mean by a "file-like object"? What Python type would that be exactly? Thank you! |
Hi @NicolasHug, sure, but I can only refer to the documentation of pyav
Although I must admit, that this is misleading, because typing only states
|
Do you think this is already handled by some of the private APIs like For context, the video decoders of torchvision aren't really maintained lately and we hope to provide better support for video decoding soon. It is possible for us to address some minor improvements as long as they're super easy, but big changes may not be in scope for torchvision. TBH, it's still not clear to me what exactly this feature request is about (i.e. what types need to be supported), so it's hard for me to give you a definite answer just yet |
I could imagine that this API could solve it as well. Effectively, this request is about allowing streams in the old api, which is not possible right now because of this line: https://github.com/pytorch/vision/blob/main/torchvision/io/video.py#L270 which expects a filename, but the pyav api could also handle a if not isinstance(filename, io.IOBase) and not os.path.exists(filename): |
Thanks for the details. OK, I guess we can move the |
@NicolasHug Thank you so much for the quick implementation! :) One week OOO and it's already in there, great! 👏 |
🚀 The feature
As the title states, I'd like to be able to pass a file-like object to
read_video
.Motivation, pitch
As far as I can see, there should be no issue allowing this, as
pyav
supports that. The currentif not os.path.exists(filename):
is the only thing preventing this, as I see it. It could be specially useful e.g. for webdataset, which currently extracts the videos to/tmp
, but could also pass it directly from memory, which would be much more efficient.I wonder if there is any reason to not expose this interface?
Alternatives
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: