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
parent f75a35f7
......@@ -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: "<<preargs;
m_args << "-profile" << profile;
if (scenelist.startsWith("consumer:")) {
// Use MLT's producer_consumer, needs a different syntax for profile:
m_args << "profile=" + profile;
}
else m_args << "-profile" << profile;
m_args << "-consumer" << rendermodule + ":" + m_dest << "progress=1" << args;
connect(m_renderProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotIsOver(int, QProcess::ExitStatus)));
m_renderProcess->setReadChannel(QProcess::StandardError);
......
......@@ -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: "<<folder;
QDir pluginsDir(folder);
foreach (QString fileName, pluginsDir.entryList(filters, QDir::Files)) {
kDebug()<<"// FOUND PLUGIN: "<<fileName<<"= "<<pluginsDir.absoluteFilePath(fileName);
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
QObject *plugin = loader.instance();
if (plugin) {
populateMenus(plugin);
m_pluginFileNames += fileName;
}
else kDebug()<<"// ERROR LOADING PLUGIN: "<<fileName<<", "<<loader.errorString ();
}
kDebug() << "// PARSING FIOLER: " << folder;
QDir pluginsDir(folder);
foreach(QString fileName, pluginsDir.entryList(filters, QDir::Files)) {
kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
QObject *plugin = loader.instance();
if (plugin) {
populateMenus(plugin);
m_pluginFileNames += fileName;
} else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
}
}
//exit(1);
}
void MainWindow::populateMenus(QObject *plugin)
{
kDebug()<<"// POP MENU";
void MainWindow::populateMenus(QObject *plugin) {
kDebug() << "// POP MENU";
QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(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"<<texts;
foreach (QString text, texts) {
QMenu *menu, const char *member,
QActionGroup *actionGroup) {
kDebug() << "// ADD to MENU" << texts;
foreach(QString text, texts) {
QAction *action = new QAction(text, plugin);
connect(action, SIGNAL(triggered()), this, member);
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<QAction *>(sender());
ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(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);
......
......@@ -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();
......
......@@ -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) {
......
......@@ -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);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment