]> git.sesse.net Git - kdenlive/blob - renderer/kdenlive_render.cpp
krazy code fixes
[kdenlive] / renderer / kdenlive_render.cpp
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20 #include <stdio.h>
21 #include <QCoreApplication>
22 #include <QStringList>
23 #include <QString>
24 #include <QtDebug>
25
26 #include "renderjob.h"
27
28 int main(int argc, char **argv) {
29     QCoreApplication app(argc, argv);
30     QStringList args = app.arguments();
31     QStringList preargs;
32     int in = -1;
33     int out = -1;
34     if (!args.isEmpty()) args.takeFirst();
35     if (args.count() >= 4) {
36         bool erase = false;
37         if (args.at(0) == "-erase") {
38             erase = true;
39             args.takeFirst();
40         }
41         bool usekuiserver = false;
42         if (args.at(0) == "-kuiserver") {
43             usekuiserver = true;
44             args.takeFirst();
45         }
46         if (args.at(0).startsWith("in=")) {
47             in = args.at(0).section('=', -1).toInt();
48             args.takeFirst();
49         }
50         if (args.at(0).startsWith("out=")) {
51             out = args.at(0).section('=', -1).toInt();
52             args.takeFirst();
53         }
54         if (args.at(0).startsWith("preargs=")) {
55             QString a = args.at(0).section('=', 1);
56             preargs = a.split(' ', QString::SkipEmptyParts);
57             args.takeFirst();
58         }
59         QString render = args.at(0);
60         args.takeFirst();
61         QString profile = args.at(0);
62         args.takeFirst();
63         QString rendermodule = args.at(0);
64         args.takeFirst();
65         QString player = args.at(0);
66         args.takeFirst();
67         QString src = args.at(0);
68         args.takeFirst();
69         QString dest = args.at(0);
70         args.takeFirst();
71         bool dualpass = false;
72         bool doerase;
73         if (args.contains("pass=2")) {
74             // dual pass encoding
75             dualpass = true;
76             doerase = false;
77             args.replace(args.indexOf("pass=2"), "pass=1");
78         } else doerase = erase;
79         qDebug() << "//STARTING RENDERING: " << erase << "," << usekuiserver << "," << render << "," << profile << "," << rendermodule << "," << player << "," << src << "," << dest << "," << preargs << "," << args << "," << in << "," << out ;
80         RenderJob *job = new RenderJob(doerase, usekuiserver, render, profile, rendermodule, player, src, dest, preargs, args, in, out);
81         job->start();
82         if (dualpass) {
83             args.replace(args.indexOf("pass=1"), "pass=2");
84             RenderJob *dualjob = new RenderJob(erase, usekuiserver, render, profile, rendermodule, player, src, dest, preargs, args, in, out);
85             QObject::connect(job, SIGNAL(renderingFinished()), dualjob, SLOT(start()));
86         }
87         app.exec();
88     } else {
89         fprintf(stderr, "Kdenlive video renderer for MLT.\nUsage: "
90                 "kdenlive_render [-erase] [-kuiserver] [in=pos] [out=pos] [render] [profile] [rendermodule] [player] [src] [dest] [[arg1] [arg2] ...]\n"
91                 "  -erase: if that parameter is present, src file will be erased at the end\n"
92                 "  -kuiserver: if that parameter is present, use KDE job tracker\n"
93                 "  in=pos: start rendering at frame pos\n"
94                 "  out=pos: end rendering at frame pos\n"
95                 "  render: path to inigo render\n"
96                 "  profile: the MLT video profile\n"
97                 "  rendermodule: the MLT consumer used for rendering, usually it is avformat\n"
98                 "  player: path to video player to play when rendering is over, use '-' to disable playing\n"
99                 "  src: source file (usually westley playlist)\n"
100                 "  dest: destination file\n"
101                 "  args: space separated libavformat arguments\n");
102     }
103 }
104