Page 1 of 1
How to do a lua tool to record an avi file???
Posted: 09.10.2008, 21:40
by MARKS
Hello all, I would like to do a kind of new tool in lua, like the edu tools, concerned to record an avi file. I did the menu with a record button and the stop button. I start reading the code in avicapture.h, avicapture.cpp and moviecapture.h, but I don't know how to manage to use them in a lua file, to give the action to the buttons. Could anyone help me, please?
Thank you.
Re: How to do a lua tool to record an avi file???
Posted: 10.10.2008, 18:38
by MARKS
Hi, all. Although my English is very poor, I'll try to explain me better.
What I want to do is use the classes movicapture and avicapture in a lua script. I know that there aren't classes in lua scripts, but is it possible to use that classes from a lua script, like in cxclass.lua in the lua edu tools.
What I want to do is a menu like this:
REC BUTTON STOP BUTTON
Size
[x] 640x480
[ ] 720x480
Frame rate
[x] 24 flps
[ ] 25 flps
Name of avi file: video.avi
Where you can choose size, framerate y name of the avi file.
Is that possible without using a celx command??
Thanks.
Re: How to do a lua tool to record an avi file???
Posted: 11.10.2008, 08:54
by Vincent
MARKS wrote:Is that possible without using a celx command??
Marks,
AFAIK, the answer is no. At least, not without adding C++ code.
The Lua Tools interacts with Celestia core using the hook protocol.
I.e., Lua Hooks are inserted in celestiacore.cpp at strategic points
so that Lua functions can be called from Celestia at these various
points. That means that you would have to modify Celestia C++ code
to handle movie capture from Lua. One other way would be to write
a lua module made in C++. Chris L. will be much more of a help here.
Re: How to do a lua tool to record an avi file???
Posted: 11.10.2008, 10:40
by selden
FWIW, you can do individual frame-grabs using CELX/LUA. You could write a loop which steps the simulation time and grabs a frame.
Re: How to do a lua tool to record an avi file???
Posted: 11.10.2008, 18:22
by MARKS
Thanks to both, Selden and Vincent.
I've tried with takescreenshot command as Selden told, with a while loop, but that stops a goto command, and I get ten screenshots which are the same view, so itsn't what i'm looking for.
I was trying to compile the whole code of celestia, I tried with mvs2003, mvs2005 and mvs2008, but, in spite of follow the steps in the forum and in the wiki, I couldn't manage to do it, I got lot of errors which i couldn't solve.
But I'm interested in that module Vincent told. How could it be? A .h file which will include the class avicapture and movicapture and its methods? Then, compiling the lua source code with this new library, could be possible use it in a lua script inside Celestia, without changing nothing in celestia source code??
Could you give any advice, please??
Thank you all.
Re: How to do a lua tool to record an avi file???
Posted: 11.10.2008, 23:17
by selden
The following scripts work fine for me.
Use this one while adjusting the window size so it's what you want
windowsize.celx
Code: Select all
-- display Celestia's window size
for v = 1,1000,1 do
x,y = celestia:getscreendimension()
s = "Window size: x,y = "..x..", "..y
celestia:flash(s)
wait (0.2)
end
Use this one to record the movie.
You will need to change this one to do as many screengrabs as you want, maybe scripting the viewpoint's location, too.
screengrab.celx
Code: Select all
-- loop grabbing Celestia windows
minute = 0
second = 0
for v = 1,15,1 do
-- Start the simulation at 12:00 25 Dec 1492 UTC
d = celestia:utctotdb(1492, 12, 25, 12, minute, second)
celestia:settime(d)
-- display which screengrab in window (appears in snapshot)
s = "movie grab # "..v
celestia:flash (s)
-- allow celestia to update window
wait (0.2)
-- record window to default directory (usually Celestia's root)
iok = celestia:takescreenshot("jpg","movie")
-- step simulated time for next screengrab
minute = minute + 1
end