2 #include "batchrender.h"
7 #include "filesystem.h"
9 #include "loadfile.inc"
13 #include "mwindowgui.h"
14 #include "pluginserver.h"
15 #include "preferences.h"
16 #include "renderfarmclient.h"
24 #define PACKAGE "cinelerra"
25 #define LOCALEDIR "/usr/share/locale"
40 int main(int argc, char *argv[])
42 // handle command line arguments first
44 ArrayList<char*> filenames;
47 int operation = DO_GUI;
48 int deamon_port = DEAMON_PORT;
49 char deamon_path[BCTEXTLEN];
50 char config_path[BCTEXTLEN];
51 char batch_path[BCTEXTLEN];
56 EDL::id_lock = new Mutex("EDL::id_lock");
58 // detect an UTF-8 locale and try to use a non-Unicode locale instead
59 // <---Beginning of dirty hack
60 // This hack will be removed as soon as Cinelerra is UTF-8 compliant
64 if ((s = getenv("LC_ALL")) ||
65 (s = getenv("LC_MESSAGES")) ||
66 (s = getenv("LC_CTYPE")) ||
67 (s = getenv ("LANG")))
69 // Test if user locale is set to Unicode
70 if (strstr(s, ".UTF-8"))
72 // extract language from language-charset@variant
73 language = strtok (s, ".@");
74 // set language as the default locale
75 setenv("LANG", language, 1);
78 // End of dirty hack --->
83 bindtextdomain (PACKAGE, LOCALEDIR);
85 setlocale (LC_MESSAGES, "");
86 setlocale (LC_CTYPE, "");
88 for(int i = 1; i < argc; i++)
90 if(!strcmp(argv[i], "-h"))
95 if(!strcmp(argv[i], "-r"))
97 operation = DO_BATCHRENDER;
100 if(argv[i + 1][0] != '-')
102 strcpy(batch_path, argv[i + 1]);
108 if(!strcmp(argv[i], "-c"))
112 strcpy(config_path, argv[i + 1]);
117 fprintf(stderr, "%s: -c needs a filename.\n", argv[0]);
121 if(!strcmp(argv[i], "-d") || !strcmp(argv[i], "-f"))
123 if(!strcmp(argv[i], "-d"))
124 operation = DO_DEAMON;
126 operation = DO_DEAMON_FG;
130 if(atol(argv[i + 1]) > 0)
132 deamon_port = atol(argv[i + 1]);
138 if(!strcmp(argv[i], "-b"))
140 operation = DO_BRENDER;
143 fprintf(stderr, "-b may not be used by the user.\n");
147 strcpy(deamon_path, argv[i + 1]);
150 if(!strcmp(argv[i], "-n"))
154 nice_value = atol(argv[i + 1]);
161 new_filename = new char[1024];
162 strcpy(new_filename, argv[i]);
163 fs.complete_path(new_filename);
165 filenames.append(new_filename);
172 if(operation == DO_GUI ||
173 operation == DO_DEAMON ||
174 operation == DO_DEAMON_FG ||
175 operation == DO_USAGE ||
176 operation == DO_BATCHRENDER)
179 CINELERRA_VERSION " "
181 " (C)2006 Heroine Virtual Ltd.\n\n"
183 PROGRAM_NAME " is free software, covered by the GNU General Public License,\n"
184 "and you are welcome to change it and/or distribute copies of it under\n"
185 "certain conditions. There is absolutely no warranty for " PROGRAM_NAME ".\n");
194 printf(_("\nUsage:\n"));
195 printf(_("%s [-f] [-c configuration] [-d port] [-n nice] [-r batch file] [filenames]\n\n"), argv[0]);
196 printf(_("-d = Run in the background as renderfarm client. The port (400) is optional.\n"));
197 printf(_("-f = Run in the foreground as renderfarm client. Substitute for -d.\n"));
198 printf(_("-n = Nice value if running as renderfarm client. (20)\n"));
199 printf(_("-c = Configuration file to use instead of %s%s.\n"),
202 printf(_("-r = batch render the contents of the batch file (%s%s) with no GUI. batch file is optional.\n"),
205 printf(_("filenames = files to load\n\n\n"));
212 if(operation == DO_DEAMON)
218 // Redhat 9 requires _exit instead of exit here.
223 RenderFarmClient client(deamon_port,
231 // Same thing without detachment
234 RenderFarmClient client(0,
244 BatchRenderThread *thread = new BatchRenderThread;
245 thread->start_rendering(config_path,
253 mwindow.create_objects(1,
257 // load the initial files on seperate tracks
260 mwindow.gui->lock_window("main");
261 mwindow.load_filenames(&filenames, LOAD_REPLACE);
262 if(filenames.total == 1)
263 mwindow.gui->mainmenu->add_load(filenames.values[0]);
264 mwindow.gui->unlock_window();
269 mwindow.save_defaults();
275 filenames.remove_all_objects();