2 #include "batchrender.h"
7 #include "filesystem.h"
10 #include "loadfile.inc"
14 #include "mwindowgui.h"
15 #include "pluginserver.h"
16 #include "preferences.h"
17 #include "renderfarmclient.h"
25 #define PACKAGE "cinelerra"
26 #define LOCALEDIR "/usr/share/locale"
41 int main(int argc, char *argv[])
43 // handle command line arguments first
45 ArrayList<char*> filenames;
48 int operation = DO_GUI;
49 int deamon_port = DEAMON_PORT;
50 char deamon_path[BCTEXTLEN];
51 char config_path[BCTEXTLEN];
52 char batch_path[BCTEXTLEN];
57 Garbage::garbage = new Garbage;
58 EDL::id_lock = new Mutex("EDL::id_lock");
60 // detect an UTF-8 locale and try to use a non-Unicode locale instead
61 // <---Beginning of dirty hack
62 // This hack will be removed as soon as Cinelerra is UTF-8 compliant
66 if ((s = getenv("LC_ALL")) ||
67 (s = getenv("LC_MESSAGES")) ||
68 (s = getenv("LC_CTYPE")) ||
69 (s = getenv ("LANG")))
71 // Test if user locale is set to Unicode
72 if (strstr(s, ".UTF-8"))
74 // extract language from language-charset@variant
75 language = strtok (s, ".@");
76 // set language as the default locale
77 setenv("LANG", language, 1);
80 // End of dirty hack --->
85 bindtextdomain (PACKAGE, LOCALEDIR);
87 setlocale (LC_MESSAGES, "");
88 setlocale (LC_CTYPE, "");
90 for(int i = 1; i < argc; i++)
92 if(!strcmp(argv[i], "-h"))
97 if(!strcmp(argv[i], "-r"))
99 operation = DO_BATCHRENDER;
102 if(argv[i + 1][0] != '-')
104 strcpy(batch_path, argv[i + 1]);
110 if(!strcmp(argv[i], "-c"))
114 strcpy(config_path, argv[i + 1]);
119 fprintf(stderr, "%s: -c needs a filename.\n", argv[0]);
123 if(!strcmp(argv[i], "-d") || !strcmp(argv[i], "-f"))
125 if(!strcmp(argv[i], "-d"))
126 operation = DO_DEAMON;
128 operation = DO_DEAMON_FG;
132 if(atol(argv[i + 1]) > 0)
134 deamon_port = atol(argv[i + 1]);
140 if(!strcmp(argv[i], "-b"))
142 operation = DO_BRENDER;
145 fprintf(stderr, "-b may not be used by the user.\n");
149 strcpy(deamon_path, argv[i + 1]);
152 if(!strcmp(argv[i], "-n"))
156 nice_value = atol(argv[i + 1]);
163 new_filename = new char[1024];
164 strcpy(new_filename, argv[i]);
165 fs.complete_path(new_filename);
167 filenames.append(new_filename);
174 if(operation == DO_GUI ||
175 operation == DO_DEAMON ||
176 operation == DO_DEAMON_FG ||
177 operation == DO_USAGE ||
178 operation == DO_BATCHRENDER)
181 CINELERRA_VERSION " "
183 " (C)2006 Heroine Virtual Ltd.\n\n"
185 PROGRAM_NAME " is free software, covered by the GNU General Public License,\n"
186 "and you are welcome to change it and/or distribute copies of it under\n"
187 "certain conditions. There is absolutely no warranty for " PROGRAM_NAME ".\n");
196 printf(_("\nUsage:\n"));
197 printf(_("%s [-f] [-c configuration] [-d port] [-n nice] [-r batch file] [filenames]\n\n"), argv[0]);
198 printf(_("-d = Run in the background as renderfarm client. The port (400) is optional.\n"));
199 printf(_("-f = Run in the foreground as renderfarm client. Substitute for -d.\n"));
200 printf(_("-n = Nice value if running as renderfarm client. (20)\n"));
201 printf(_("-c = Configuration file to use instead of %s%s.\n"),
204 printf(_("-r = batch render the contents of the batch file (%s%s) with no GUI. batch file is optional.\n"),
207 printf(_("filenames = files to load\n\n\n"));
214 if(operation == DO_DEAMON)
220 // Redhat 9 requires _exit instead of exit here.
225 RenderFarmClient client(deamon_port,
233 // Same thing without detachment
236 RenderFarmClient client(0,
246 BatchRenderThread *thread = new BatchRenderThread;
247 thread->start_rendering(config_path,
255 mwindow.create_objects(1,
259 // load the initial files on seperate tracks
262 mwindow.gui->lock_window("main");
263 mwindow.load_filenames(&filenames, LOAD_REPLACE);
264 if(filenames.total == 1)
265 mwindow.gui->mainmenu->add_load(filenames.values[0]);
266 mwindow.gui->unlock_window();
271 mwindow.save_defaults();
277 filenames.remove_all_objects();