clementfarabet / lua---ffmpeg Goto Github PK
View Code? Open in Web Editor NEWAn interface between ffmpeg and Lua/Torch
An interface between ffmpeg and Lua/Torch
local ffmpeg_cmd = (FFMPEG .. ' -r ' .. self.fps)
==>
local ffmpeg_cmd = ('ffmpeg -r ' .. self.fps)
The rockspec for this package in https://github.com/torch/rocks points to the tag 1.0-0 and the fix for the missing sys functions in the last commit is not included there. The package won't work correctly if installed with luarocks.
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?
I am not sure if this is an issue or my misusage but I am going to report it anyways.
The following usage loads a video, but at the end of the constructor vid.n_channels is set to 0 by vid:clear()
require 'ffmpeg'
vid = ffmpeg.Video('office20150910.mp4')
print(vid.n_channels) --- prints 0
due to the fact vid.n_channels=0, the following functions won't work.
print(vid:forward()) -- returns {}
vid:save('test.avi') -- generate empty test.avi
but if I manually set n_channels back to 1, everything work as expected.
vid = ffmpeg.Video('office20150910.mp4')
vid.n_channels = 1
print(#(vid:forward())) -- this one return a 3d tensor of the frame.
The current API forces you to set both the fps and the video resolution. It would be good to be able to query the video fps/resolution and/or be able to use the native resolution.
Hello,
It seems that after a few calls on ffmpeg.Video with the load parameter set to true, the memory used by the previous video is not freed even though the same object is used to recieve the return value of ffmpeg.Video.
Regards
EDIT : The memory leak is confirmed. Its due to image:load. Lua gc cant free tensors created by image:load...
https://groups.google.com/forum/#!topic/torch7/mWcQjP2WEVQ
FFMPEG bindings for Lua don't work. I have reproduced the error below.
ffmpeg works through command line. But not through Lua.
th> require 'ffmpeg'
{
Video : {...}
}
[0.0162s]
th> ffmpeg.Video()
WARNIN
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Video
loads a video into a table of tensors:
+ relies on ffpmeg, which must be installed
+ creates a local scratch/ to store temp frames on disk
> usage:
Video{
[path = string] -- path to video
[width = number] -- width [default = 320]
[height = number] -- height [default = 240]
[zoom = number] -- zoom factor [default = 1]
[fps = number] -- frames per second [default = 10]
[length = number] -- length, in seconds [default = 10]
[seek = number] -- seek to pos. in seconds [default = 0]
[channel = number] -- video channel [default = 0]
[load = boolean] -- loads frames after conversion [default = true]
[delete = boolean] -- clears (rm) frames after load [default = true]
[encoding = string] -- format of dumped frames [default = png]
[tensor = torch.Tensor] -- provide a packed tensor (NxCxHxW or NxHxW), that bypasses path
[destFolder = string] -- destination folder [default = scratch]
[silent = boolean] -- suppress output [default = false]
}
Video{width=number, path=string}
Video(string, ...)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/home/utkarsha/torch/install/share/lua/5.1/xlua/init.lua:320: error
stack traceback:
[C]: in function 'error'
/home/utkarsha/torch/install/share/lua/5.1/xlua/init.lua:320: in function 'error'
/home/utkarsha/torch/install/share/lua/5.1/xlua/init.lua:543: in function 'unpack'
/home/utkarsha/torch/install/share/lua/5.1/xlua/init.lua:603: in function 'unpack_class'
/home/utkarsha/torch/install/share/lua/5.1/ffmpeg/init.lua:64: in function '__init'
/home/utkarsha/torch/install/share/lua/5.1/torch/init.lua:91: in function </home/utkarsha/torch/install/share/lua/5.1/torch/init.lua:87>
[C]: in function 'Video'
[string "_RESULT={ffmpeg.Video()}"]:1: in main chunk
[C]: in function 'xpcall'
/home/utkarsha/torch/install/share/lua/5.1/trepl/init.lua:650: in function 'repl'
...rsha/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x00406670
t7> ffmpeg.Video()
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Video
loads a video into a table of tensors:
+ relies on ffpmeg, which must be installed
+ creates a local scratch/ to store temp frames on disk
> usage:
Video{
[path = string] -- path to video
[width = number] -- width [default = 320]
[height = number] -- height [default = 240]
[fps = number] -- frames per second [default = 10]
[length = number] -- length, in seconds [default = 10]
[seek = number] -- seek to pos. in seconds [default = 0]
[channel = number] -- video channel [default = 0]
[load = boolean] -- loads frames after conversion [default = true]
[delete = boolean] -- clears (rm) frames after load [default = true]
[encoding = string] -- format of dumped frames [default = png]
[tensor = torch.Tensor] -- provide a packed tensor (NxCxHxW or NxHxW), that bypasses path
}
Video{width=number, path=string}
Video(string, ...)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
If the fps = 10 and length = 10s, therefore there could be only 100 photograms?
How does this work?
Thanks
Thank you for the good tools, it's very helpful to handle video files.
There is one little thing that makes me annoying.
When I use ffmpeg, there are so many log messages.
I want to reduce log messages. I saw the code and found that if silent=true then it would work. But I don't know how to set silent=true. Can you help me with that?
Hi,
I am getting the following error when loading the video. I am using CentOS.
Have tried installing image module but the issue persists.
/usr/local/torch/install/share/lua/5.1/xlua/init.lua:360: module 'libpng' not found:
no field package.preload['libpng']
no file '/root/.luarocks/share/lua/5.1/libpng.lua'
no file '/root/.luarocks/share/lua/5.1/libpng/init.lua'
no file '/usr/local/torch/install/share/lua/5.1/libpng.lua'
no file '/usr/local/torch/install/share/lua/5.1/libpng/init.lua'
no file './libpng.lua'
no file '/usr/local/torch/install/share/luajit-2.1.0-beta1/libpng.lua'
no file '/usr/local/share/lua/5.1/libpng.lua'
no file '/usr/local/share/lua/5.1/libpng/init.lua'
no file '/usr/local/torch/install/lib/libpng.so'
no file '/root/.luarocks/lib/lua/5.1/libpng.so'
no file '/usr/local/torch/install/lib/lua/5.1/libpng.so'
no file './libpng.so'
no file '/usr/local/lib/lua/5.1/libpng.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
warning: could not be loaded (is it installed?)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.