X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=renderer%2Fkdenlive_render.cpp;h=72fa66ed46a9d6b8a23fec729963055bb0c5189b;hb=56aee6aedeeed3efd10ada8fe3c229eddc01ef05;hp=807deb88b2f3c0267dc7bda570a24b6904891dea;hpb=e44eb3032532a0b849fee4a11bbdc8e0f3c01709;p=kdenlive diff --git a/renderer/kdenlive_render.cpp b/renderer/kdenlive_render.cpp index 807deb88..72fa66ed 100644 --- a/renderer/kdenlive_render.cpp +++ b/renderer/kdenlive_render.cpp @@ -21,84 +21,120 @@ #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") { + if (args.at(0) == QLatin1String("-erase")) { erase = true; - args.takeFirst(); + args.removeFirst(); } bool usekuiserver = false; - if (args.at(0) == "-kuiserver") { + if (args.at(0) == QLatin1String("-kuiserver")) { usekuiserver = true; - args.takeFirst(); - } - if (args.at(0).startsWith("in=")) { - in = args.at(0).section('=', -1).toInt(); - args.takeFirst(); + args.removeFirst(); } - if (args.at(0).startsWith("out=")) { - out = args.at(0).section('=', -1).toInt(); - args.takeFirst(); + if (QString(args.at(0)).startsWith(QLatin1String("-pid:"))) { + pid = QString(args.at(0)).section(QLatin1Char(':'), 1).toInt(); + args.removeFirst(); } - if (args.at(0).startsWith("preargs=")) { - QString a = args.at(0).section('=', 1); - preargs = a.split(" ", QString::SkipEmptyParts); - args.takeFirst(); + + if (QString(args.at(0)).startsWith(QLatin1String("-locale:"))) { + locale = QString(args.at(0)).section(QLatin1Char(':'), 1); + args.removeFirst(); } - QString render = args.at(0); - args.takeFirst(); - QString profile = args.at(0); - args.takeFirst(); - QString rendermodule = 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(); + if (args.at(0).startsWith(QLatin1String("in="))) + in = args.takeFirst().section(QLatin1Char('='), -1).toInt(); + if (args.at(0).startsWith(QLatin1String("out="))) + out = args.takeFirst().section(QLatin1Char('='), -1).toInt(); + if (args.at(0).startsWith(QLatin1String("preargs="))) + preargs = args.takeFirst().section(QLatin1Char('='), 1).split(QLatin1Char(' '), 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(QLatin1String("consumer:")); + QUrl desturl = QUrl::fromEncoded(args.takeFirst().toUtf8()); + QString dest = desturl.path(); bool dualpass = false; bool doerase; - if (args.contains("pass=2")) { + QString vpre; + + int vprepos = args.indexOf(QRegExp(QLatin1String("vpre=.*"))); + if (vprepos >= 0) { + vpre=args.at(vprepos); + } + QStringList vprelist = vpre.replace(QLatin1String("vpre="), QLatin1String("")).split(QLatin1Char(',')); + if (vprelist.size() > 0) { + args.replaceInStrings(QRegExp(QLatin1String("^vpre=.*")), QString::fromLatin1("vpre=%1").arg(vprelist.at(0))); + } + + if (args.contains(QLatin1String("pass=2"))) { // dual pass encoding dualpass = true; doerase = false; - args.replace(args.indexOf("pass=2"), "pass=1"); - } else doerase = erase; + args.replace(args.indexOf(QLatin1String("pass=2")), QLatin1String("pass=1")); + if (args.contains(QLatin1String("vcodec=libx264"))) args << QString::fromLatin1("passlogfile=%1").arg(dest + QLatin1String(".log")); + } else { + args.removeAll(QLatin1String("pass=1")); + doerase = erase; + } + + // Decode metadata + for (int i = 0; i < args.count(); ++i) { + if (args.at(i).startsWith(QLatin1String("meta.attr"))) { + QString data = args.at(i); + args.replace(i, data.section(QLatin1Char('='), 0, 0) + QLatin1String("=\"") + QUrl::fromPercentEncoding(data.section(QLatin1Char('='), 1).toUtf8()) + QLatin1String("\"")); + } + } + qDebug() << "//STARTING RENDERING: " << erase << "," << usekuiserver << "," << render << "," << profile << "," << rendermodule << "," << player << "," << src << "," << dest << "," << preargs << "," << args << "," << in << "," << out ; - RenderJob *job = new RenderJob(doerase, 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) { - args.replace(args.indexOf("pass=1"), "pass=2"); - RenderJob *dualjob = new RenderJob(erase, usekuiserver, render, profile, rendermodule, player, src, dest, preargs, args, in, out); + if (vprelist.size()>1) + args.replaceInStrings(QRegExp(QLatin1String("^vpre=.*")),QString::fromLatin1("vpre=%1").arg(vprelist.at(1))); + args.replace(args.indexOf(QLatin1String("pass=1")), QLatin1String("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] [-kuiserver] [in=pos] [out=pos] [render] [profile] [rendermodule] [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" + " -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 render\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"); } }