clementfarabet / lua---ffmpeg

An interface between ffmpeg and Lua/Torch
21 stars 17 forks source link

Doesn't return a table of tensors #14

Closed jrbtaylor closed 8 years ago

jrbtaylor commented 8 years ago

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?

Charlie-Steiner commented 8 years ago

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

jrbtaylor commented 8 years ago

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.