How to do a lua tool to record an avi file???

All about writing scripts for Celestia in Lua and the .cel system
Topic author
MARKS
Posts: 8
Joined: 11.03.2007
With us: 17 years 8 months
Location: Spain

How to do a lua tool to record an avi file???

Post #1by MARKS » 09.10.2008, 21:40

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.

Topic author
MARKS
Posts: 8
Joined: 11.03.2007
With us: 17 years 8 months
Location: Spain

Re: How to do a lua tool to record an avi file???

Post #2by MARKS » 10.10.2008, 18:38

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.

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Re: How to do a lua tool to record an avi file???

Post #3by Vincent » 11.10.2008, 08:54

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.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 3 months
Location: NY, USA

Re: How to do a lua tool to record an avi file???

Post #4by selden » 11.10.2008, 10:40

FWIW, you can do individual frame-grabs using CELX/LUA. You could write a loop which steps the simulation time and grabs a frame.
Selden

Topic author
MARKS
Posts: 8
Joined: 11.03.2007
With us: 17 years 8 months
Location: Spain

Re: How to do a lua tool to record an avi file???

Post #5by MARKS » 11.10.2008, 18:22

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.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 3 months
Location: NY, USA

Re: How to do a lua tool to record an avi file???

Post #6by selden » 11.10.2008, 23:17

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
Selden


Return to “Scripting”