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"
22 #define PACKAGE "cinelerra"
23 #define LOCALEDIR "/usr/share/locale"
38 int main(int argc, char *argv[])
40 // handle command line arguments first
42 ArrayList<char*> filenames;
45 int operation = DO_GUI;
46 int deamon_port = DEAMON_PORT;
47 char deamon_path[BCTEXTLEN];
48 char config_path[BCTEXTLEN];
49 char batch_path[BCTEXTLEN];
57 // detect an UTF-8 locale and try to use a non-Unicode locale instead
58 // <---Beginning of dirty hack
59 // This hack will be removed as soon as Cinelerra is UTF-8 compliant
63 if ((s = getenv("LC_ALL")) ||
64 (s = getenv("LC_MESSAGES")) ||
65 (s = getenv("LC_CTYPE")) ||
66 (s = getenv ("LANG")))
68 // Test if user locale is set to Unicode
69 if (strstr(s, ".UTF-8"))
71 // extract language from language-charset@variant
72 language = strtok (s, ".@");
73 // set language as the default locale
74 setenv("LANG", language, 1);
77 // End of dirty hack --->
82 bindtextdomain (PACKAGE, LOCALEDIR);
84 setlocale (LC_MESSAGES, "");
85 setlocale (LC_CTYPE, "");
87 for(int i = 1; i < argc; i++)
89 if(!strcmp(argv[i], "-h"))
94 if(!strcmp(argv[i], "-r"))
96 operation = DO_BATCHRENDER;
99 if(argv[i + 1][0] != '-')
101 strcpy(batch_path, argv[i + 1]);
107 if(!strcmp(argv[i], "-c"))
111 strcpy(config_path, argv[i + 1]);
116 fprintf(stderr, "%s: -c needs a filename.\n", argv[0]);
120 if(!strcmp(argv[i], "-d") || !strcmp(argv[i], "-f"))
122 if(!strcmp(argv[i], "-d"))
123 operation = DO_DEAMON;
125 operation = DO_DEAMON_FG;
129 if(atol(argv[i + 1]) > 0)
131 deamon_port = atol(argv[i + 1]);
137 if(!strcmp(argv[i], "-b"))
139 operation = DO_BRENDER;
142 fprintf(stderr, "-b may not be used by the user.\n");
146 strcpy(deamon_path, argv[i + 1]);
149 if(!strcmp(argv[i], "-n"))
153 nice_value = atol(argv[i + 1]);
160 new_filename = new char[1024];
161 strcpy(new_filename, argv[i]);
162 fs.complete_path(new_filename);
164 filenames.append(new_filename);
171 if(operation == DO_GUI ||
172 operation == DO_DEAMON ||
173 operation == DO_DEAMON_FG ||
174 operation == DO_USAGE ||
175 operation == DO_BATCHRENDER)
178 CINELERRA_VERSION " "
180 " (C)2005 Heroine Virtual Ltd.\n\n"
182 PROGRAM_NAME " is free software, covered by the GNU General Public License,\n"
183 "and you are welcome to change it and/or distribute copies of it under\n"
184 "certain conditions. There is absolutely no warranty for " PROGRAM_NAME ".\n");
193 printf(_("\nUsage:\n"));
194 printf(_("%s [-f] [-c configuration] [-d port] [-n nice] [-r batch file] [filenames]\n\n"), argv[0]);
195 printf(_("-d = Run in the background as renderfarm client. The port (400) is optional.\n"));
196 printf(_("-f = Run in the foreground as renderfarm client. Substitute for -d.\n"));
197 printf(_("-n = Nice value if running as renderfarm client. (20)\n"));
198 printf(_("-c = Configuration file to use instead of %s%s.\n"),
201 printf(_("-r = batch render the contents of the batch file (%s%s) with no GUI. batch file is optional.\n"),
204 printf(_("filenames = files to load\n\n\n"));
211 if(operation == DO_DEAMON)
217 // Redhat 9 requires _exit instead of exit here.
222 RenderFarmClient client(deamon_port,
230 // Same thing without detachment
233 RenderFarmClient client(0,
243 BatchRenderThread *thread = new BatchRenderThread;
244 thread->start_rendering(config_path,
252 mwindow.create_objects(1,
256 // load the initial files on seperate tracks
259 mwindow.gui->lock_window();
260 mwindow.load_filenames(&filenames, LOAD_REPLACE);
261 if(filenames.total == 1)
262 mwindow.gui->mainmenu->add_load(filenames.values[0]);
263 mwindow.gui->unlock_window();
268 mwindow.save_defaults();
274 filenames.remove_all_objects();