pythonalgorithmpytorchram

Save video to Torch tensor


I have a long video (~20.000 frames) of resolution 480x854. I want to save this whole video to a torch.tensor (maybe .pt file). However, my RAM is not enough to load the whole video at once. Is there a solution to do this? I don't really want to split it into multiple smaller files...

Edit: I just knew about video compression. Turns out video uses a much more efficienty way to store data, rather than naively stacking frames. So I guess storing the original video to tensor would not be possible, unless resolution and temporal downsampling are used.


Solution

  • Turns out the small memory of a video is due to efficient encoding algorithm :D So it is just not possible to achieve that same size under a tensor format (which basically saves each image separately) without decreasing the quality of the original video.