summaryrefslogtreecommitdiff
path: root/html/examples/makevideo.lua
blob: 1cb52fc6a8ff370f2bf6786767f8a30874cd05ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
-- lua5.1 makevideo.lua newfile.wmv DSC0*.jpg

require"imlua"
require"imlua_wmv"

err_msg = {
  "No error.",
  "Error while opening the file.",
  "Error while accessing the file.",
  "Invalid or unrecognized file format.",
  "Invalid or unsupported data.",
  "Invalid or unsupported compression.",
  "Insuficient memory",
  "Interrupted by the counter",
}

-- Margin parameters
new_filename = arg[1]
filename1 = arg[2]
if (not new_filename or not filename1) then
  error("invalid parameters")
end

function ProcessImageFile(file_name, ifile)
  print("Loading File: "..file_name)
  local image, err = im.FileImageLoad(file_name);
  if (err and err ~= im.ERR_NONE) then
    error(err_msg[err+1])
  end

  err = ifile:SaveImage(image)
  if (err and err ~= im.ERR_NONE) then
    error(err_msg[err+1])
  end

  image:Destroy()
end

ifile = im.FileNew(new_filename, "WMV")

ifile:SetAttribute("FPS", im.FLOAT, {15}) -- Frames per second

file_count = 0
for index,value in ipairs(arg) do
  if (index > 5) then
    ProcessImageFile(arg[index], ifile)
    file_count = file_count + 1
  end
end

ifile:Close()

if (file_count > 1) then
  print("Processed "..file_count.." Files.")
end
print("Saved File: "..new_filename)