Code Monkey home page Code Monkey logo

Comments (6)

NicolasHug avatar NicolasHug commented on June 25, 2024

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!

from vision.

voegtlel avatar voegtlel commented on June 25, 2024

Hi @NicolasHug,

sure, but I can only refer to the documentation of pyav

av.open(file, mode='r', **kwargs)
Main entrypoint to opening files/streams.

Parameters:
file (str) – The file to open, which can be either a string or a file-like object.

Although I must admit, that this is misleading, because typing only states str as type, but the documented string says, that file-like objects are allowed. I believe they refer to io, which is also what I'd understand:

The io module provides Python’s main facilities for dealing with various types of I/O. There are three main types of I/O: text I/O, binary I/O and raw I/O. These are generic categories, and various backing stores can be used for each of them. A concrete object belonging to any of these categories is called a file object. Other common terms are stream and file-like object.

from vision.

NicolasHug avatar NicolasHug commented on June 25, 2024

Do you think this is already handled by some of the private APIs like _read_video_from_memory ?

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

from vision.

voegtlel avatar voegtlel commented on June 25, 2024

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 BytesIO object. I.e. if that line would be like:

if not isinstance(filename, io.IOBase) and not os.path.exists(filename):

from vision.

NicolasHug avatar NicolasHug commented on June 25, 2024

Thanks for the details.

OK, I guess we can move the if not os.path.exists(filename): within the if get_video_backend() != "pyav": block and just let pyav do its own input checking.

from vision.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.