From: Jean-Baptiste Mardelle Date: Mon, 5 Jan 2009 21:32:12 +0000 (+0000) Subject: Use the new MLT's producer_consumer to render to a different size than the project... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=2854b18ee58617c0ef48870c1705397ebb09c365;p=kdenlive Use the new MLT's producer_consumer to render to a different size than the project profile: http://www.kdenlive.org/mantis/view.php?id=323 svn path=/branches/KDE4/; revision=2871 --- diff --git a/renderer/renderjob.cpp b/renderer/renderjob.cpp index 1abda7af..34b8bcd5 100644 --- a/renderer/renderjob.cpp +++ b/renderer/renderjob.cpp @@ -46,7 +46,11 @@ RenderJob::RenderJob(bool erase, const QString &renderer, const QString &profile if (out != -1) m_args << "out=" + QString::number(out); m_args << preargs; //qDebug()<<"PRE ARGS: "<setReadChannel(QProcess::StandardError); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index dbae087f..5e0c8b62 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -382,47 +382,44 @@ bool MainWindow::queryClose() { void MainWindow::loadPlugins() { - foreach (QObject *plugin, QPluginLoader::staticInstances()) - populateMenus(plugin); + foreach(QObject *plugin, QPluginLoader::staticInstances()) + populateMenus(plugin); QStringList directories = KGlobal::dirs()->findDirs("module", QString()); QStringList filters; filters << "libkdenlive*"; foreach(const QString &folder, directories) { - kDebug()<<"// PARSING FIOLER: "<(factory()->container("generators", this)); ClipGenerator *iGenerator = qobject_cast(plugin); - kDebug()<<"// POP MENU 2"; - if (addMenu) kDebug()<<"// POP MENU 3"; + kDebug() << "// POP MENU 2"; + if (addMenu) kDebug() << "// POP MENU 3"; if (iGenerator) addToMenu(plugin, iGenerator->generators(), addMenu, SLOT(generateClip()), - NULL); + NULL); } void MainWindow::addToMenu(QObject *plugin, const QStringList &texts, - QMenu *menu, const char *member, - QActionGroup *actionGroup) -{ - kDebug()<<"// ADD to MENU"<addAction(action); @@ -434,21 +431,19 @@ void MainWindow::addToMenu(QObject *plugin, const QStringList &texts, } } -void MainWindow::aboutPlugins() -{ +void MainWindow::aboutPlugins() { //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this); //dialog.exec(); } -void MainWindow::generateClip() -{ +void MainWindow::generateClip() { QAction *action = qobject_cast(sender()); ClipGenerator *iGenerator = qobject_cast(action->parent()); KUrl clipUrl = iGenerator->generatedClip(action->text(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576); if (!clipUrl.isEmpty()) { - m_projectList->slotAddClip(clipUrl); + m_projectList->slotAddClip(clipUrl); } } @@ -1375,7 +1370,7 @@ void MainWindow::slotEditProjectSettings() { void MainWindow::slotRenderProject() { if (!m_renderWidget) { m_renderWidget = new RenderWidget(this); - connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double))); + connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool))); if (m_activeDocument) { m_renderWidget->setProfile(m_activeDocument->mltProfile()); m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration()); @@ -1387,7 +1382,7 @@ void MainWindow::slotRenderProject() { m_renderWidget->show(); } -void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd) { +void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd, bool resizeProfile) { if (dest.isEmpty()) return; int in; int out; @@ -1417,7 +1412,20 @@ void MainWindow::slotDoRender(const QString &dest, const QString &render, const KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)")); return; } - args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args; + args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer; + + for (int i = 0; i < avformat_args.count(); i++) { + if (avformat_args.at(i).startsWith("profile=")) { + if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true; + break; + } + } + + if (resizeProfile) { + // The rendering profile is different from project profile, so use MLT's special producer_consumer + args << "consumer:" + temp.fileName(); + } else args << temp.fileName(); + args << dest << avformat_args; QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render"); if (!QFile::exists(renderer)) renderer = "kdenlive_render"; QProcess::startDetached(renderer, args); diff --git a/src/mainwindow.h b/src/mainwindow.h index 7b886f46..e862926c 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -186,8 +186,8 @@ private: void loadPlugins(); void populateMenus(QObject *plugin); void addToMenu(QObject *plugin, const QStringList &texts, - QMenu *menu, const char *member, - QActionGroup *actionGroup); + QMenu *menu, const char *member, + QActionGroup *actionGroup); void aboutPlugins(); QStringList m_pluginFileNames; @@ -220,7 +220,7 @@ private slots: void slotSwitchMarkersComments(); void slotSwitchSnap(); void slotRenderProject(); - void slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd); + void slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd, bool resizeProfile); void slotFullScreen(); void slotUpdateDocumentState(bool modified); void slotZoomIn(); diff --git a/src/renderwidget.cpp b/src/renderwidget.cpp index 8b605646..43478daf 100644 --- a/src/renderwidget.cpp +++ b/src/renderwidget.cpp @@ -401,7 +401,22 @@ void RenderWidget::slotExport() { renderArgs.replace("%dar", "@" + QString::number(m_profile.display_aspect_num) + "/" + QString::number(m_profile.display_aspect_den)); if (m_view.force_progressive->checkState() == Qt::Checked) renderArgs.append(" progressive=1"); else if (m_view.force_progressive->checkState() == Qt::Unchecked) renderArgs.append(" progressive=0"); - emit doRender(m_view.out_file->url().path(), item->data(RenderRole).toString(), overlayargs, renderArgs.simplified().split(' '), m_view.render_zone->isChecked(), m_view.play_after->isChecked(), startPos, endPos); + + // Check if the rendering profile is different from project profile, + // in which case we need to use the producer_comsumer from MLT + bool resizeProfile = false; + + QString std = item->data(ParamsRole).toString(); + if (resizeProfile == false && std.contains(" s=")) { + QString subsize = std.section(" s=", 1, 1); + subsize = subsize.section(' ', 0, 0).toLower(); + if (subsize != "%widthx%height") { + const QString currentSize = QString::number(m_profile.width) + 'x' + QString::number(m_profile.height); + if (subsize != currentSize) resizeProfile = true; + } + } + + emit doRender(m_view.out_file->url().path(), item->data(RenderRole).toString(), overlayargs, renderArgs.simplified().split(' '), m_view.render_zone->isChecked(), m_view.play_after->isChecked(), startPos, endPos, resizeProfile); } void RenderWidget::setProfile(MltVideoProfile profile) { diff --git a/src/renderwidget.h b/src/renderwidget.h index ec2b6b38..1acf1c57 100644 --- a/src/renderwidget.h +++ b/src/renderwidget.h @@ -57,7 +57,7 @@ private: void parseFile(QString exportFile, bool editable); void updateButtons(); signals: - void doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double); + void doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool); };