0

A similar question has been asked before, but there is no good answer. I have an mp4 that I receive as Python bytes (If I need to write a c++ converter I can do that, though may need to be picklable). I want to convert these bytes to video numpy (as done by opencv) so that I can process them in an ML data loader. OpenCV has VideoCapture, but unfortunately that only works with files not with bytes. I do not want to write the bytes to disk and the re-read as that will kill my performance. You might ask, "why don't I re-write the loader/dataset?" I'm using a very efficient generic loader provided by the company that reads all file data in as bytes then the user converts to the desired objects using transformations.

similar question posted Read video from bytes

desertnaut
  • 57,590
  • 26
  • 140
  • 166
user3071643
  • 1,405
  • 1
  • 15
  • 18
  • 1
    OpenCV can't do that. You'll need to write your own decoder (maybe using ffmpeg ?) and then feed the data to Python. (or maybe find another library that can, but that's off-topic) That last bit is quite easy, if you can using something like pybind11 or boost.python. – Dan Mašek May 13 '21 at 16:47
  • 1
    I posted a [solution](https://stackoverflow.com/questions/60558412/how-to-decode-a-video-memory-file-byte-string-and-step-through-it-frame-by-f) for similar problem (using FFmpeg). I think it may be helpful. – Rotem May 13 '21 at 18:28

0 Answers0