2 #include "batchrender.h"
6 #include "filesystem.h"
8 #include "loadfile.inc"
11 #include "mwindowgui.h"
12 #include "pluginserver.h"
13 #include "preferences.h"
14 #include "renderfarmclient.h"
20 #define PACKAGE "cinelerra"
21 #define LOCALEDIR "/usr/share/locale"
36 int main(int argc, char *argv[])
38 // handle command line arguments first
40 ArrayList<char*> filenames;
43 int operation = DO_GUI;
44 int deamon_port = DEAMON_PORT;
45 char deamon_path[BCTEXTLEN];
46 char config_path[BCTEXTLEN];
47 char batch_path[BCTEXTLEN];
55 // detect an UTF-8 locale and try to use a non-Unicode locale instead
56 // <---Beginning of dirty hack
57 // This hack will be removed as soon as Cinelerra is UTF-8 compliant
61 if ((s = getenv("LC_ALL")) ||
62 (s = getenv("LC_MESSAGES")) ||
63 (s = getenv("LC_CTYPE")) ||
64 (s = getenv ("LANG")))
66 // Test if user locale is set to Unicode
67 if (strstr(s, ".UTF-8"))
69 // extract language from language-charset@variant
70 language = strtok (s, ".@");
71 // set language as the default locale
72 setenv("LANG", language, 1);
75 // End of dirty hack --->
80 bindtextdomain (PACKAGE, LOCALEDIR);
82 setlocale (LC_MESSAGES, "");
83 setlocale (LC_CTYPE, "");
85 for(int i = 1; i < argc; i++)
87 if(!strcmp(argv[i], "-h"))
92 if(!strcmp(argv[i], "-r"))
94 operation = DO_BATCHRENDER;
97 if(argv[i + 1][0] != '-')
99 strcpy(batch_path, argv[i + 1]);
105 if(!strcmp(argv[i], "-c"))
109 strcpy(config_path, argv[i + 1]);
114 fprintf(stderr, "%s: -c needs a filename.\n", argv[0]);
118 if(!strcmp(argv[i], "-d") || !strcmp(argv[i], "-f"))
120 if(!strcmp(argv[i], "-d"))
121 operation = DO_DEAMON;
123 operation = DO_DEAMON_FG;
127 if(atol(argv[i + 1]) > 0)
129 deamon_port = atol(argv[i + 1]);
135 if(!strcmp(argv[i], "-b"))
137 operation = DO_BRENDER;
140 fprintf(stderr, "-b may not be used by the user.\n");
144 strcpy(deamon_path, argv[i + 1]);
147 if(!strcmp(argv[i], "-n"))
151 nice_value = atol(argv[i + 1]);
158 new_filename = new char[1024];
159 strcpy(new_filename, argv[i]);
160 fs.complete_path(new_filename);
162 filenames.append(new_filename);
169 if(operation == DO_GUI ||
170 operation == DO_DEAMON ||
171 operation == DO_DEAMON_FG ||
172 operation == DO_USAGE ||
173 operation == DO_BATCHRENDER)
176 CINELERRA_VERSION " "
178 " (C)2005 Heroine Virtual Ltd.\n\n"
180 PROGRAM_NAME " is free software, covered by the GNU General Public License,\n"
181 "and you are welcome to change it and/or distribute copies of it under\n"
182 "certain conditions. There is absolutely no warranty for " PROGRAM_NAME ".\n");
191 printf(_("\nUsage:\n"));
192 printf(_("%s [-f] [-c configuration] [-d port] [-n nice] [-r batch file] [filenames]\n\n"), argv[0]);
193 printf(_("-d = Run in the background as renderfarm client. The port (400) is optional.\n"));
194 printf(_("-f = Run in the foreground as renderfarm client. Substitute for -d.\n"));
195 printf(_("-n = Nice value if running as renderfarm client. (20)\n"));
196 printf(_("-c = Configuration file to use instead of %s%s.\n"),
199 printf(_("-r = batch render the contents of the batch file (%s%s) with no GUI. batch file is optional.\n"),
202 printf(_("filenames = files to load\n\n\n"));
209 if(operation == DO_DEAMON)
215 // Redhat 9 requires _exit instead of exit here.
220 RenderFarmClient client(deamon_port,
228 // Same thing without detachment
231 RenderFarmClient client(0,
241 BatchRenderThread *thread = new BatchRenderThread;
242 thread->start_rendering(config_path,
250 mwindow.create_objects(1,
254 // load the initial files on seperate tracks
257 mwindow.gui->lock_window();
258 mwindow.load_filenames(&filenames, LOAD_REPLACE);
259 if(filenames.total == 1)
260 mwindow.gui->mainmenu->add_load(filenames.values[0]);
261 mwindow.gui->unlock_window();
266 mwindow.save_defaults();
272 filenames.remove_all_objects();