clementfarabet / lua---ffmpeg

An interface between ffmpeg and Lua/Torch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't return a table of tensors

jrbtaylor opened this issue · comments

If I call this as vid = ffmpeg.Video('somevideo.mp4') and then check the contents of vid with print(vid) it just shows "ffmpeg.Video", no "{...}" and I cannot seem to index into it. What is the format/type returned?

Use vid:totensor(1) to get the video data as a tensor.

Thanks. I should have replied sooner as I figured this out after looking at the code.

If I may suggest something: the totensor() function uses copy() to populate the tensor with the table entries, which creates a copy of the memory. It's both inefficient and slower. A better way would be simply initializing the tensor (e.g. tensor = torch.Tensor(#sequence,sequence[1]:size(1),self.height,self.width) and then tensor[i] = sequence[i]inside the for loop.

i.e. copy by reference instead of by value. I ran out of memory otherwise using the code as is.