X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=renderer%2Fkdenlive_render.cpp;h=593d002c367df9ce5968b01754ff0bdb0676a9ba;hb=c3302003093710ee247ad84c0fe2ef3c579d417f;hp=a79f030b3200140b289c847418f44746b5d37eeb;hpb=082c0c36bfe1f878a1c77e2c7d9b35f2cf6ce9ff;p=kdenlive diff --git a/renderer/kdenlive_render.cpp b/renderer/kdenlive_render.cpp index a79f030b..593d002c 100644 --- a/renderer/kdenlive_render.cpp +++ b/renderer/kdenlive_render.cpp @@ -1,95 +1,141 @@ -/**************************************************************************** -** -** Copyright (C) 2006-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools applications of the Qt Toolkit. -** -** This file may be used under the terms of the GNU General Public -** License versions 2.0 or 3.0 as published by the Free Software -** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Alternatively you may (at -** your option) use any later version of the GNU General Public -** License if such license has been publicly approved by Trolltech ASA -** (or its successors, if any) and the KDE Free Qt Foundation. In -** addition, as a special exception, Trolltech gives you certain -** additional rights. These rights are described in the Trolltech GPL -** Exception version 1.2, which can be found at -** http://www.trolltech.com/products/qt/gplexception/ and in the file -** GPL_EXCEPTION.txt in this package. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. If -** you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** In addition, as a special exception, Trolltech, as the sole -** copyright holder for Qt Designer, grants users of the Qt/Eclipse -** Integration plug-in the right for the Qt/Eclipse Integration to -** link to functionality provided by Qt Designer and its related -** libraries. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly -** granted herein. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ +/*************************************************************************** + * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ #include #include #include #include +#include +#include #include "renderjob.h" -int main(int argc, char **argv) { +int main(int argc, char **argv) +{ QCoreApplication app(argc, argv); QStringList args = app.arguments(); + QStringList preargs; + QString locale; + int pid = 0; int in = -1; int out = -1; - if (!args.isEmpty()) args.takeFirst(); - if (args.count() >= 4) { + if (args.count() >= 7) { + // Remove program name + args.removeFirst(); + bool erase = false; if (args.at(0) == "-erase") { erase = true; - args.takeFirst(); + args.removeFirst(); + } + bool usekuiserver = false; + if (args.at(0) == "-kuiserver") { + usekuiserver = true; + args.removeFirst(); + } + if (QString(args.at(0)).startsWith("-pid:")) { + pid = QString(args.at(0)).section(':', 1).toInt(); + args.removeFirst(); + } + + if (QString(args.at(0)).startsWith("-locale:")) { + locale = QString(args.at(0)).section(':', 1); + args.removeFirst(); + } + if (args.at(0).startsWith("in=")) + in = args.takeFirst().section('=', -1).toInt(); + if (args.at(0).startsWith("out=")) + out = args.takeFirst().section('=', -1).toInt(); + if (args.at(0).startsWith("preargs=")) + preargs = args.takeFirst().section('=', 1).split(' ', QString::SkipEmptyParts); + + QString render = args.takeFirst(); + QString profile = args.takeFirst(); + QString rendermodule = args.takeFirst(); + QString player = args.takeFirst(); + QByteArray srcString = args.takeFirst().toUtf8(); + QUrl srcurl = QUrl::fromEncoded(srcString); + QString src = srcurl.path(); + // The QUrl path() strips the consumer: protocol, so re-add it if necessary + if (srcString.startsWith("consumer:")) + src.prepend("consumer:"); + QUrl desturl = QUrl::fromEncoded(args.takeFirst().toUtf8()); + QString dest = desturl.path(); + bool dualpass = false; + bool doerase; + QString vpre; + + int vprepos = args.indexOf(QRegExp("vpre=.*")); + if (vprepos >= 0) { + vpre=args.at(vprepos); + } + QStringList vprelist = vpre.replace("vpre=", "").split(','); + if (vprelist.size() > 0) { + args.replaceInStrings(QRegExp("^vpre=.*"), QString("vpre=").append(vprelist.at(0))); } - if (args.at(0).startsWith("in=")) { - in = args.at(0).section('=', -1).toInt(); - args.takeFirst(); + + if (args.contains("pass=2")) { + // dual pass encoding + dualpass = true; + doerase = false; + args.replace(args.indexOf("pass=2"), "pass=1"); + if (args.contains("vcodec=libx264")) args << QString("passlogfile=%1").arg(dest + ".log"); + } else { + args.removeAll("pass=1"); + doerase = erase; } - if (args.at(0).startsWith("out=")) { - out = args.at(0).section('=', -1).toInt(); - args.takeFirst(); + + // Decode metadata + for (int i = 0; i < args.count(); ++i) { + if (args.at(i).startsWith("meta.attr")) { + QString data = args.at(i); + args.replace(i, data.section('=', 0, 0) + "=\"" + QUrl::fromPercentEncoding(data.section('=', 1).toUtf8()) + "\""); + } } - QString render = args.at(0); - args.takeFirst(); - QString player = args.at(0); - args.takeFirst(); - QString src = args.at(0); - args.takeFirst(); - QString dest = args.at(0); - args.takeFirst(); - RenderJob *job = new RenderJob(erase, render, player, src, dest, args, in, out); + + qDebug() << "//STARTING RENDERING: " << erase << "," << usekuiserver << "," << render << "," << profile << "," << rendermodule << "," << player << "," << src << "," << dest << "," << preargs << "," << args << "," << in << "," << out ; + RenderJob *job = new RenderJob(doerase, usekuiserver, pid, render, profile, rendermodule, player, src, dest, preargs, args, in, out); + if (!locale.isEmpty()) job->setLocale(locale); job->start(); + if (dualpass) { + if (vprelist.size()>1) + args.replaceInStrings(QRegExp("^vpre=.*"),QString("vpre=").append(vprelist.at(1))); + args.replace(args.indexOf("pass=1"), "pass=2"); + RenderJob *dualjob = new RenderJob(erase, usekuiserver, pid, render, profile, rendermodule, player, src, dest, preargs, args, in, out); + QObject::connect(job, SIGNAL(renderingFinished()), dualjob, SLOT(start())); + } app.exec(); } else { fprintf(stderr, "Kdenlive video renderer for MLT.\nUsage: " - "kdenlive_render [-erase] [in=pos] [out=pos] [renderer] [player] [src] [dest] [[arg1] [arg2] ...]\n" + "kdenlive_render [-erase] [-kuiserver] [-locale:LOCALE] [in=pos] [out=pos] [render] [profile] [rendermodule] [player] [src] [dest] [[arg1] [arg2] ...]\n" " -erase: if that parameter is present, src file will be erased at the end\n" + " -kuiserver: if that parameter is present, use KDE job tracker\n" + " -locale:LOCALE : set a locale for rendering. For example, -locale:fr_FR.UTF-8 will use a french locale (comma as numeric separator)\n" " in=pos: start rendering at frame pos\n" " out=pos: end rendering at frame pos\n" - " render: path to inigo rendrer\n" + " render: path to MLT melt renderer\n" + " profile: the MLT video profile\n" + " rendermodule: the MLT consumer used for rendering, usually it is avformat\n" " player: path to video player to play when rendering is over, use '-' to disable playing\n" - " src: source file (usually westley playlist)\n" - " dest: destination file\n" - " args: space separated libavformat arguments\n"); + " src: source file (usually MLT XML)\n" + " dest: destination file\n" + " args: space separated libavformat arguments\n"); } }