]> git.sesse.net Git - kdenlive/blobdiff - src/renderwidget.cpp
Fix detection of missing codecs in render dialog, use kmessagewidget to inform user
[kdenlive] / src / renderwidget.cpp
index 77937ccd899ae02730eec79fcea8f2abce0042a4..39cc878a84708d3332bd70c2fe682b130e4a5571 100644 (file)
@@ -22,6 +22,7 @@
 #include "kdenlivesettings.h"
 #include "ui_saveprofile_ui.h"
 #include "timecode.h"
+#include "profilesdialog.h"
 
 #include <KStandardDirs>
 #include <KDebug>
@@ -32,7 +33,6 @@
 #include <KColorScheme>
 #include <KNotification>
 #include <KStartupInfo>
-// #include <knewstuff2/engine.h>
 
 #include <QDomDocument>
 #include <QItemDelegate>
@@ -44,6 +44,8 @@
 #include <QProcess>
 #include <QDBusConnectionInterface>
 #include <QDBusInterface>
+#include <QThread>
+#include <QScriptEngine>
 
 const int GroupRole = Qt::UserRole;
 const int ExtensionRole = GroupRole + 1;
@@ -53,6 +55,10 @@ const int ParamsRole = GroupRole + 4;
 const int EditableRole = GroupRole + 5;
 const int MetaGroupRole = GroupRole + 6;
 const int ExtraRole = GroupRole + 7;
+const int BitratesRole = GroupRole + 8;
+const int DefaultBitrateRole = GroupRole + 9;
+const int AudioBitratesRole = GroupRole + 10;
+const int DefaultAudioBitrateRole = GroupRole + 11;
 
 // Running job status
 const int WAITINGJOB = 0;
@@ -60,7 +66,7 @@ const int RUNNINGJOB = 1;
 const int FINISHEDJOB = 2;
 
 
-RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
+RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidget * parent) :
         QDialog(parent),
         m_projectFolder(projectfolder),
         m_blockProcessing(false)
@@ -83,14 +89,25 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
 
     m_view.buttonFavorite->setIcon(KIcon("favorites"));
     m_view.buttonFavorite->setToolTip(i18n("Copy profile to favorites"));
+    
+    m_view.advanced_params->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
 
     if (KdenliveSettings::showrenderparams()) {
         m_view.buttonInfo->setDown(true);
     } else m_view.advanced_params->hide();
+    
+    m_view.proxy_render->setHidden(!enableProxy);
 
-    m_view.rescale_size->setInputMask("0099\\x0099");
-    m_view.rescale_size->setText("320x240");
+    m_view.encoder_threads->setMaximum(QThread::idealThreadCount());
+    m_view.encoder_threads->setValue(KdenliveSettings::encodethreads());
+    connect(m_view.encoder_threads, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateEncodeThreads(int)));
 
+    m_view.rescale_keep->setChecked(KdenliveSettings::rescalekeepratio());
+    connect(m_view.rescale_width, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateRescaleWidth(int)));
+    connect(m_view.rescale_height, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateRescaleHeight(int)));
+    m_view.rescale_keep->setIcon(KIcon("insert-link"));
+    m_view.rescale_keep->setToolTip(i18n("Preserve aspect ratio"));
+    connect(m_view.rescale_keep, SIGNAL(clicked()), this, SLOT(slotSwitchAspectRatio()));
 
     connect(m_view.buttonRender, SIGNAL(clicked()), this, SLOT(slotPrepareExport()));
     connect(m_view.buttonGenerateScript, SIGNAL(clicked()), this, SLOT(slotGenerateScript()));
@@ -102,9 +119,20 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
     m_view.format_list->setAlternatingRowColors(true);
     m_view.size_list->setAlternatingRowColors(true);
 
+    KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
+    QColor bg = scheme.background(KColorScheme::NegativeBackground).color();
+    m_view.errorBox->setStyleSheet(QString("QGroupBox { background-color: rgb(%1, %2, %3); border-radius: 5px;}; ").arg(bg.red()).arg(bg.green()).arg(bg.blue()));
+    int height = QFontInfo(font()).pixelSize();
+    m_view.errorIcon->setPixmap(KIcon("dialog-warning").pixmap(height, height));
+    m_view.errorBox->setHidden(true);
+
+    connect(m_view.export_audio, SIGNAL(stateChanged(int)), this, SLOT(slotUpdateAudioLabel(int)));
+    m_view.export_audio->setCheckState(Qt::PartiallyChecked);
+
     parseProfiles();
     parseScriptFiles();
-
+    m_view.running_jobs->setUniformRowHeights(false);
+    m_view.scripts_list->setUniformRowHeights(false);
     connect(m_view.start_script, SIGNAL(clicked()), this, SLOT(slotStartScript()));
     connect(m_view.delete_script, SIGNAL(clicked()), this, SLOT(slotDeleteScript()));
     connect(m_view.scripts_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckScript()));
@@ -126,7 +154,7 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
     connect(m_view.buttonClose, SIGNAL(clicked()), this, SLOT(hide()));
     connect(m_view.buttonClose2, SIGNAL(clicked()), this, SLOT(hide()));
     connect(m_view.buttonClose3, SIGNAL(clicked()), this, SLOT(hide()));
-    connect(m_view.rescale, SIGNAL(toggled(bool)), m_view.rescale_size, SLOT(setEnabled(bool)));
+    connect(m_view.rescale, SIGNAL(toggled(bool)), m_view.rescale_box, SLOT(setEnabled(bool)));
     connect(m_view.destination_list, SIGNAL(activated(int)), this, SLOT(refreshCategory()));
     connect(m_view.out_file, SIGNAL(textChanged(const QString &)), this, SLOT(slotUpdateButtons()));
     connect(m_view.out_file, SIGNAL(urlSelected(const KUrl &)), this, SLOT(slotUpdateButtons(const KUrl &)));
@@ -142,16 +170,18 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
     connect(m_view.guide_end, SIGNAL(activated(int)), this, SLOT(slotCheckStartGuidePosition()));
     connect(m_view.guide_start, SIGNAL(activated(int)), this, SLOT(slotCheckEndGuidePosition()));
 
-    connect(m_view.format_selection, SIGNAL(activated(int)), this, SLOT(refreshView()));
+    connect(m_view.tc_overlay, SIGNAL(toggled(bool)), m_view.tc_type, SLOT(setEnabled(bool)));
 
     m_view.buttonRender->setEnabled(false);
     m_view.buttonGenerateScript->setEnabled(false);
-    m_view.rescale_size->setEnabled(false);
+    m_view.rescale_box->setEnabled(false);
     m_view.guides_box->setVisible(false);
     m_view.open_dvd->setVisible(false);
     m_view.create_chapter->setVisible(false);
     m_view.open_browser->setVisible(false);
     m_view.error_box->setVisible(false);
+    m_view.tc_type->setEnabled(false);
+    m_view.checkTwoPass->setEnabled(false);
 
     m_view.splitter->setStretchFactor(1, 5);
     m_view.splitter->setStretchFactor(0, 2);
@@ -163,7 +193,6 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
     m_view.running_jobs->setItemDelegate(m_jobsDelegate);
 
     QHeaderView *header = m_view.running_jobs->header();
-    QFontMetrics fm = fontMetrics();
     header->setResizeMode(0, QHeaderView::Fixed);
     header->resizeSection(0, 30);
     header->setResizeMode(1, QHeaderView::Interactive);
@@ -189,11 +218,24 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
     }
 
     QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
-    if (!interface || (!interface->isServiceRegistered("org.kde.ksmserver") && !interface->isServiceRegistered("org.gnome.SessionManager"))) {
+    if (!interface || (!interface->isServiceRegistered("org.kde.ksmserver") && !interface->isServiceRegistered("org.gnome.SessionManager")))
         m_view.shutdown->setEnabled(false);
-    }
 
     focusFirstVisibleItem();
+    adjustSize();
+
+#if KDE_IS_VERSION(4,7,0)
+    m_infoMessage = new KMessageWidget;
+    QGridLayout *s =  static_cast <QGridLayout*> (m_view.tab->layout());
+    s->addWidget(m_infoMessage, 12, 0, 1, -1);
+    m_infoMessage->hide();
+#endif
+}
+
+QSize RenderWidget::sizeHint() const
+{
+    // Make sure the widget has minimum size on opening
+    return QSize(200, 200);
 }
 
 RenderWidget::~RenderWidget()
@@ -226,7 +268,7 @@ void RenderWidget::showInfoPanel()
     }
 }
 
-void RenderWidget::setDocumentPath(const QString path)
+void RenderWidget::setDocumentPath(const QString &path)
 {
     if (m_view.out_file->url().directory() == KUrl(m_projectFolder).directory()) {
         const QString fileName = m_view.out_file->url().fileName();
@@ -334,17 +376,18 @@ void RenderWidget::slotSaveProfile()
     QString dest = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();
 
     QString customGroup = m_view.format_list->currentItem()->text();
-    if (customGroup.isEmpty()) customGroup = i18n("Custom");
+    if (customGroup.isEmpty()) customGroup = i18nc("Group Name", "Custom");
     ui.group_name->setText(customGroup);
 
-    ui.parameters->setText(m_view.advanced_params->toPlainText());
+    QStringList arguments = m_view.advanced_params->toPlainText().split(" ", QString::SkipEmptyParts);
+    ui.parameters->setText(arguments.join(" "));
     ui.extension->setText(m_view.size_list->currentItem()->data(ExtensionRole).toString());
     ui.profile_name->setFocus();
 
     if (d->exec() == QDialog::Accepted && !ui.profile_name->text().simplified().isEmpty()) {
         QString newProfileName = ui.profile_name->text().simplified();
         QString newGroupName = ui.group_name->text().simplified();
-        if (newGroupName.isEmpty()) newGroupName = i18n("Custom");
+        if (newGroupName.isEmpty()) newGroupName = i18nc("Group Name", "Custom");
         QString newMetaGroupId = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();
 
         QDomDocument doc;
@@ -353,7 +396,24 @@ void RenderWidget::slotSaveProfile()
         profileElement.setAttribute("category", newGroupName);
         profileElement.setAttribute("destinationid", newMetaGroupId);
         profileElement.setAttribute("extension", ui.extension->text().simplified());
-        profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
+        QString args = ui.parameters->toPlainText().simplified();
+        profileElement.setAttribute("args", args);
+        if (args.contains("%bitrate")) {
+            // profile has a variable bitrate
+            profileElement.setAttribute("defaultbitrate", m_view.comboBitrates->currentText());
+            QStringList bitrateValues;
+            for (int i = 0; i < m_view.comboBitrates->count(); i++)
+                bitrateValues << m_view.comboBitrates->itemText(i);
+            profileElement.setAttribute("bitrates", bitrateValues.join(","));
+        }
+        if (args.contains("%audiobitrate")) {
+            // profile has a variable bitrate
+            profileElement.setAttribute("defaultaudiobitrate", m_view.comboAudioBitrates->currentText());
+            QStringList bitrateValues;
+            for (int i = 0; i < m_view.comboAudioBitrates->count(); i++)
+                bitrateValues << m_view.comboAudioBitrates->itemText(i);
+            profileElement.setAttribute("audiobitrates", bitrateValues.join(","));
+        }
         doc.appendChild(profileElement);
         saveProfile(doc.documentElement());
 
@@ -437,10 +497,14 @@ void RenderWidget::slotCopyToFavorites()
     QDomDocument doc;
     QDomElement profileElement = doc.createElement("profile");
     profileElement.setAttribute("name", currentProfile);
-    profileElement.setAttribute("category", i18n("Custom"));
+    profileElement.setAttribute("category", i18nc("Category Name", "Custom"));
     profileElement.setAttribute("destinationid", "favorites");
     profileElement.setAttribute("extension", extension);
     profileElement.setAttribute("args", params);
+    profileElement.setAttribute("bitrates", item->data(BitratesRole).toStringList().join(","));
+    profileElement.setAttribute("defaultbitrate", item->data(DefaultBitrateRole).toString());
+    profileElement.setAttribute("audiobitrates", item->data(AudioBitratesRole).toStringList().join(","));
+    profileElement.setAttribute("defaultaudiobitrate", item->data(DefaultAudioBitrateRole).toString());
     doc.appendChild(profileElement);
     saveProfile(doc.documentElement());
     parseProfiles(m_view.destination_list->itemData(m_view.destination_list->currentIndex(), Qt::UserRole).toString(), currentGroup, currentProfile);
@@ -467,7 +531,7 @@ void RenderWidget::slotEditProfile()
     QString dest = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();
 
     QString customGroup = m_view.format_list->currentItem()->text();
-    if (customGroup.isEmpty()) customGroup = i18n("Custom");
+    if (customGroup.isEmpty()) customGroup = i18nc("Group Name", "Custom");
     ui.group_name->setText(customGroup);
 
     ui.profile_name->setText(currentProfile);
@@ -503,7 +567,7 @@ void RenderWidget::slotEditProfile()
 
         QString newProfileName = ui.profile_name->text().simplified();
         QString newGroupName = ui.group_name->text().simplified();
-        if (newGroupName.isEmpty()) newGroupName = i18n("Custom");
+        if (newGroupName.isEmpty()) newGroupName = i18nc("Group Name", "Custom");
         QString newMetaGroupId = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();
         QDomNodeList profilelist = doc.elementsByTagName("profile");
         int i = 0;
@@ -529,7 +593,25 @@ void RenderWidget::slotEditProfile()
         profileElement.setAttribute("category", newGroupName);
         profileElement.setAttribute("destinationid", newMetaGroupId);
         profileElement.setAttribute("extension", ui.extension->text().simplified());
-        profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
+        QString args = ui.parameters->toPlainText().simplified();
+        profileElement.setAttribute("args", args);
+        if (args.contains("%bitrate")) {
+            // profile has a variable bitrate
+            profileElement.setAttribute("defaultbitrate", m_view.comboBitrates->currentText());
+            QStringList bitrateValues;
+            for (int i = 0; i < m_view.comboBitrates->count(); i++)
+                bitrateValues << m_view.comboBitrates->itemText(i);
+            profileElement.setAttribute("bitrates", bitrateValues.join(","));
+        }
+        if (args.contains("%audiobitrate")) {
+            // profile has a variable bitrate
+            profileElement.setAttribute("defaultaudiobitrate", m_view.comboAudioBitrates->currentText());
+            QStringList bitrateValues;
+            for (int i = 0; i < m_view.comboAudioBitrates->count(); i++)
+                bitrateValues << m_view.comboAudioBitrates->itemText(i);
+            profileElement.setAttribute("audiobitrates", bitrateValues.join(","));
+        }
+
         profiles.appendChild(profileElement);
 
         //QCString save = doc.toString().utf8();
@@ -652,19 +734,23 @@ void RenderWidget::slotPrepareExport(bool scriptExport)
         KMessageBox::sorry(this, i18n("Cannot find the melt program required for rendering (part of Mlt)"));
         return;
     }
-    if (m_view.play_after->isChecked() && KdenliveSettings::defaultplayerapp().isEmpty())
+    if (m_view.play_after->isChecked() && KdenliveSettings::defaultplayerapp().isEmpty()) {
         KMessageBox::sorry(this, i18n("Cannot play video after rendering because the default video player application is not set.\nPlease define it in Kdenlive settings dialog."));
+    }
     QString chapterFile;
     if (m_view.create_chapter->isChecked()) chapterFile = m_view.out_file->url().path() + ".dvdchapter";
 
     // mantisbt 1051
-    KStandardDirs::makeDir(m_view.out_file->url().directory());
+    if (!KStandardDirs::makeDir(m_view.out_file->url().directory())) {
+        KMessageBox::sorry(this, i18n("The directory %1, could not be created.\nPlease make sure you have the required permissions.", m_view.out_file->url().directory()));
+        return;
+    }
 
     emit prepareRenderingData(scriptExport, m_view.render_zone->isChecked(), chapterFile);
 }
 
 
-void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const QString &playlistPath, const QString &scriptPath)
+void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const QString &playlistPath, const QString &scriptPath, bool exportAudio)
 {
     QListWidgetItem *item = m_view.size_list->currentItem();
     if (!item) return;
@@ -690,7 +776,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     QStringList overlayargs;
     if (m_view.tc_overlay->isChecked()) {
         QString filterFile = KStandardDirs::locate("appdata", "metadata.properties");
-        overlayargs << "meta.attr.timecode=1" << "meta.attr.timecode.markup=#timecode";
+        overlayargs << "meta.attr.timecode=1" << "meta.attr.timecode.markup=#" + QString(m_view.tc_type->currentIndex() ? "frame" : "timecode");
         overlayargs << "-attach" << "data_feed:attr_check" << "-attach";
         overlayargs << "data_show:" + filterFile << "_loader=1" << "dynamic=1";
     }
@@ -700,6 +786,14 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     if (!scriptExport) render_process_args << "-erase";
     if (KdenliveSettings::usekuiserver()) render_process_args << "-kuiserver";
 
+    // get process id
+    render_process_args << QString("-pid:%1").arg(QCoreApplication::applicationPid());
+
+    // Set locale for render process if required
+    if (QLocale().decimalPoint() != QLocale::system().decimalPoint()) {
+        render_process_args << QString("-locale:%1").arg(QLocale().name());
+    }
+
     double guideStart = 0;
     double guideEnd = 0;
 
@@ -708,12 +802,16 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
         double fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
         guideStart = m_view.guide_start->itemData(m_view.guide_start->currentIndex()).toDouble();
         guideEnd = m_view.guide_end->itemData(m_view.guide_end->currentIndex()).toDouble();
-        render_process_args << "in=" + QString::number(GenTime(guideStart).frames(fps)) << "out=" + QString::number(GenTime(guideEnd).frames(fps));
+        render_process_args << "in=" + QString::number((int) GenTime(guideStart).frames(fps)) << "out=" + QString::number((int) GenTime(guideEnd).frames(fps));
     }
 
     if (!overlayargs.isEmpty()) render_process_args << "preargs=" + overlayargs.join(" ");
 
-    render_process_args << KdenliveSettings::rendererpath() << m_profile.path << item->data(RenderRole).toString();
+    if (scriptExport)
+        render_process_args << "$MELT";
+    else
+        render_process_args << KdenliveSettings::rendererpath();
+    render_process_args << m_profile.path << item->data(RenderRole).toString();
     if (m_view.play_after->isChecked()) render_process_args << KdenliveSettings::KdenliveSettings::defaultplayerapp();
     else render_process_args << "-";
 
@@ -723,21 +821,28 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     int width;
     int height;
     if (m_view.rescale->isChecked() && m_view.rescale->isEnabled()) {
-        width = m_view.rescale_size->text().section('x', 0, 0).toInt();
-        height = m_view.rescale_size->text().section('x', 1, 1).toInt();
+        width = m_view.rescale_width->value();
+        height = m_view.rescale_height->value();
     } else {
         width = m_profile.width;
         height = m_profile.height;
     }
-    renderArgs.replace("%dar", '@' + QString::number(m_profile.display_aspect_num) + '/' + QString::number(m_profile.display_aspect_den));
+
+    //renderArgs.replace("%width", QString::number((int)(m_profile.height * m_profile.display_aspect_num / (double) m_profile.display_aspect_den + 0.5)));
+    //renderArgs.replace("%height", QString::number((int)m_profile.height));
 
     // Adjust scanning
     if (m_view.scanning_list->currentIndex() == 1) renderArgs.append(" progressive=1");
     else if (m_view.scanning_list->currentIndex() == 2) renderArgs.append(" progressive=0");
 
     // disable audio if requested
-    if (!m_view.export_audio->isChecked())
-        renderArgs.append(" an=1 ");
+    if (!exportAudio) renderArgs.append(" an=1 ");
+
+    // Set the thread counts
+    if (!renderArgs.contains("threads=")) {
+        renderArgs.append(QString(" threads=%1").arg(KdenliveSettings::encodethreads()));
+    }
+    renderArgs.append(QString(" real_time=-%1").arg(KdenliveSettings::mltthreads()));
 
     // Check if the rendering profile is different from project profile,
     // in which case we need to use the producer_comsumer from MLT
@@ -747,7 +852,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     QString subsize = currentSize;
     if (std.startsWith("s=")) {
         subsize = std.section(' ', 0, 0).toLower();
-        subsize = subsize.section("=", 1, 1);
+        subsize = subsize.section('=', 1, 1);
     } else if (std.contains(" s=")) {
         subsize = std.section(" s=", 1, 1);
         subsize = subsize.section(' ', 0, 0).toLower();
@@ -758,25 +863,37 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     }
     bool resizeProfile = (subsize != currentSize);
     QStringList paramsList = renderArgs.split(" ", QString::SkipEmptyParts);
-    for (int i = 0; i < paramsList.count(); i++) {
-        if (paramsList.at(i).startsWith("profile=")) {
-            if (paramsList.at(i).section('=', 1) != m_profile.path) resizeProfile = true;
-            break;
+
+    QScriptEngine sEngine;
+    sEngine.globalObject().setProperty("bitrate", m_view.comboBitrates->currentText());
+    sEngine.globalObject().setProperty("audiobitrate", m_view.comboAudioBitrates->currentText());
+    sEngine.globalObject().setProperty("dar", '@' + QString::number(m_profile.display_aspect_num) + '/' + QString::number(m_profile.display_aspect_den));
+    sEngine.globalObject().setProperty("passes", static_cast<int>(m_view.checkTwoPass->isChecked()) + 1);
+
+    for (int i = 0; i < paramsList.count(); ++i) {
+        QString paramName = paramsList.at(i).section('=', 0, 0);
+        QString paramValue = paramsList.at(i).section('=', 1, 1);
+        // If the profiles do not match we need to use the consumer tag
+        if (paramName == "mlt_profile=" && paramValue != m_profile.path) {
+            resizeProfile = true;
+        }
+        // evaluate expression
+        if (paramValue.startsWith('%')) {
+            paramValue = sEngine.evaluate(paramValue.remove(0, 1)).toString();
+            paramsList[i] = paramName + '=' + paramValue;
         }
+        sEngine.globalObject().setProperty(paramName.toUtf8().constData(), paramValue);
     }
 
-    if (resizeProfile) render_process_args << "consumer:" + playlistPath;
-    else render_process_args << playlistPath;
-    render_process_args << dest;
+    if (resizeProfile)
+        render_process_args << "consumer:" + (scriptExport ? "$SOURCE" : playlistPath);
+    else
+        render_process_args <<  (scriptExport ? "$SOURCE" : playlistPath);
+    render_process_args << (scriptExport ? "$TARGET" : KUrl(dest).url());
     render_process_args << paramsList;
 
     QString group = m_view.size_list->currentItem()->data(MetaGroupRole).toString();
 
-    QStringList renderParameters;
-    renderParameters << dest << item->data(RenderRole).toString() << renderArgs.simplified();
-    renderParameters << QString::number(zoneIn) << QString::number(zoneOut) << QString::number(m_view.play_after->isChecked());
-    renderParameters << QString::number(guideStart) << QString::number(guideEnd) << QString::number(resizeProfile);
-
     QString scriptName;
     if (scriptExport) {
         // Generate script file
@@ -788,11 +905,11 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
         QTextStream outStream(&file);
         outStream << "#! /bin/sh" << "\n" << "\n";
         outStream << "SOURCE=" << "\"" + playlistPath + "\"" << "\n";
-        outStream << "TARGET=" << "\"" + dest + "\"" << "\n";
+        outStream << "TARGET=" << "\"" + KUrl(dest).url() + "\"" << "\n";
         outStream << "RENDERER=" << "\"" + m_renderer + "\"" << "\n";
-        outStream << "MELT=" << "\"" + render_process_args.takeFirst() + "\"" << "\n";
+        outStream << "MELT=" << "\"" + KdenliveSettings::rendererpath() + "\"" << "\n";
         outStream << "PARAMETERS=" << "\"" + render_process_args.join(" ") + "\"" << "\n";
-        outStream << "$RENDERER $MELT $PARAMETERS" << "\n" << "\n";
+        outStream << "$RENDERER $PARAMETERS" << "\n" << "\n";
         if (file.error() != QFile::NoError) {
             KMessageBox::error(this, i18n("Cannot write to file %1", scriptPath));
             file.close();
@@ -805,11 +922,33 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
         m_view.tabWidget->setCurrentIndex(2);
         return;
     }
-    renderParameters << scriptName;
-    m_view.tabWidget->setCurrentIndex(1);
 
     // Save rendering profile to document
-    emit selectedRenderProfile(m_view.size_list->currentItem()->data(MetaGroupRole).toString(), m_view.size_list->currentItem()->data(GroupRole).toString(), m_view.size_list->currentItem()->text(), dest);
+    QMap <QString, QString> renderProps;
+    renderProps.insert("renderdestination", m_view.size_list->currentItem()->data(MetaGroupRole).toString());
+    renderProps.insert("rendercategory", m_view.size_list->currentItem()->data(GroupRole).toString());
+    renderProps.insert("renderprofile", m_view.size_list->currentItem()->text());
+    renderProps.insert("renderurl", dest);
+    renderProps.insert("renderzone", QString::number(m_view.render_zone->isChecked()));
+    renderProps.insert("renderguide", QString::number(m_view.render_guide->isChecked()));
+    renderProps.insert("renderstartguide", QString::number(m_view.guide_start->currentIndex()));
+    renderProps.insert("renderendguide", QString::number(m_view.guide_end->currentIndex()));
+    renderProps.insert("renderendguide", QString::number(m_view.guide_end->currentIndex()));
+    renderProps.insert("renderscanning", QString::number(m_view.scanning_list->currentIndex()));
+    int export_audio = 0;
+    if (m_view.export_audio->checkState() == Qt::Checked) export_audio = 2;
+    else if (m_view.export_audio->checkState() == Qt::Unchecked) export_audio = 1;
+    renderProps.insert("renderexportaudio", QString::number(export_audio));
+    renderProps.insert("renderrescale", QString::number(m_view.rescale->isChecked()));
+    renderProps.insert("renderrescalewidth", QString::number(m_view.rescale_width->value()));
+    renderProps.insert("renderrescaleheight", QString::number(m_view.rescale_height->value()));
+    renderProps.insert("rendertcoverlay", QString::number(m_view.tc_overlay->isChecked()));
+    renderProps.insert("rendertctype", QString::number(m_view.tc_type->currentIndex()));
+    renderProps.insert("renderratio", QString::number(m_view.rescale_keep->isChecked()));
+    renderProps.insert("renderplay", QString::number(m_view.play_after->isChecked()));
+    renderProps.insert("rendertwopass", QString::number(m_view.checkTwoPass->isChecked()));
+
+    emit selectedRenderProfile(renderProps);
 
     // insert item in running jobs list
     QTreeWidgetItem *renderItem;
@@ -834,9 +973,9 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     if (group == "dvd") {
         if (m_view.open_dvd->isChecked()) {
             renderItem->setData(0, Qt::UserRole, group);
-            if (renderArgs.contains("profile=")) {
+            if (renderArgs.contains("mlt_profile=")) {
                 // rendering profile contains an MLT profile, so pass it to the running jog item, useful for dvd
-                QString prof = renderArgs.section("profile=", 1, 1);
+                QString prof = renderArgs.section("mlt_profile=", 1, 1);
                 prof = prof.section(' ', 0, 0);
                 kDebug() << "// render profile: " << prof;
                 renderItem->setData(0, Qt::UserRole + 1, prof);
@@ -851,6 +990,10 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
         }
     }
     renderItem->setData(1, Qt::UserRole + 3, render_process_args);
+    if (exportAudio == false) renderItem->setData(1, Qt::UserRole + 5, i18n("Video without audio track"));
+    else  renderItem->setData(1, Qt::UserRole + 5, QString());
+    m_view.running_jobs->setCurrentItem(renderItem);
+    m_view.tabWidget->setCurrentIndex(1);
     checkRenderStatus();
 }
 
@@ -886,7 +1029,9 @@ void RenderWidget::startRendering(QTreeWidgetItem *item)
             item->setData(1, Qt::UserRole, i18n("Rendering crashed"));
             item->setIcon(0, KIcon("dialog-close"));
             item->setData(2, Qt::UserRole, 100);
-        } else KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", item->text(1)), QPixmap(), this);
+        } else {
+            KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", item->text(1)), QPixmap(), this);
+        }
     } else {
         // Script item
         if (QProcess::startDetached(item->data(1, Qt::UserRole + 3).toString()) == false) {
@@ -912,10 +1057,13 @@ int RenderWidget::waitingJobsCount() const
 void RenderWidget::setProfile(MltVideoProfile profile)
 {
     m_profile = profile;
-    //WARNING: this way to tell the video standard is a bit hackish...
-    if (m_profile.description.contains("pal", Qt::CaseInsensitive) || m_profile.description.contains("25", Qt::CaseInsensitive) || m_profile.description.contains("50", Qt::CaseInsensitive)) m_view.format_selection->setCurrentIndex(0);
-    else m_view.format_selection->setCurrentIndex(1);
     m_view.scanning_list->setCurrentIndex(0);
+    m_view.rescale_width->setValue(KdenliveSettings::defaultrescalewidth());
+    if (!m_view.rescale_keep->isChecked()) {
+        m_view.rescale_height->blockSignals(true);
+        m_view.rescale_height->setValue(KdenliveSettings::defaultrescaleheight());
+        m_view.rescale_height->blockSignals(false);
+    }
     refreshView();
 }
 
@@ -937,11 +1085,12 @@ void RenderWidget::refreshCategory()
         m_view.open_dvd->setVisible(false);
         m_view.create_chapter->setVisible(false);
     }
-    if (destination == "websites") m_view.open_browser->setVisible(true);
-    else m_view.open_browser->setVisible(false);
-    if (!destination.isEmpty() && QString("dvd websites audioonly").contains(destination))
-        m_view.rescale->setEnabled(false);
-    else m_view.rescale->setEnabled(true);
+
+    if (destination == "websites")
+        m_view.open_browser->setVisible(true);
+    else
+        m_view.open_browser->setVisible(false);
+
     // hide groups that are not in the correct destination
     for (int i = 0; i < m_renderCategory.count(); i++) {
         sizeItem = m_renderCategory.at(i);
@@ -959,7 +1108,9 @@ void RenderWidget::refreshCategory()
     }
     if (!item) {
         m_view.format_list->setEnabled(false);
+        m_view.format_list->clear();
         m_view.size_list->setEnabled(false);
+        m_view.size_list->clear();
         m_view.size_list->blockSignals(false);
         m_view.format_list->blockSignals(false);
         return;
@@ -968,8 +1119,10 @@ void RenderWidget::refreshCategory()
         m_view.size_list->setEnabled(true);
     }
 
-    if (m_view.format_list->count() > 1) m_view.format_list->setVisible(true);
-    else m_view.format_list->setVisible(false);
+    if (m_view.format_list->count() > 1)
+        m_view.format_list->setVisible(true);
+    else
+        m_view.format_list->setVisible(false);
     refreshView();
 }
 
@@ -985,6 +1138,7 @@ void RenderWidget::refreshView()
     if (m_view.destination_list->currentIndex() > 0)
         destination = m_view.destination_list->itemData(m_view.destination_list->currentIndex()).toString();
     KIcon brokenIcon("dialog-close");
+    KIcon warningIcon("dialog-warning");
 
     const QStringList formatsList = KdenliveSettings::supportedformats();
     const QStringList vcodecsList = KdenliveSettings::videocodecs();
@@ -994,23 +1148,38 @@ void RenderWidget::refreshView()
     const QColor disabled = scheme.foreground(KColorScheme::InactiveText).color();
     const QColor disabledbg = scheme.background(KColorScheme::NegativeBackground).color();
 
-
+    double project_framerate = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
     for (int i = 0; i < m_renderItems.count(); i++) {
         sizeItem = m_renderItems.at(i);
         QListWidgetItem *dupItem = NULL;
         if ((sizeItem->data(GroupRole).toString() == group || sizeItem->data(GroupRole).toString().isEmpty()) && sizeItem->data(MetaGroupRole).toString() == destination) {
             std = sizeItem->data(StandardRole).toString();
             if (!std.isEmpty()) {
-                if (std.contains("PAL", Qt::CaseInsensitive) && m_view.format_selection->currentIndex() == 0) dupItem = sizeItem->clone();
-                else if (std.contains("NTSC", Qt::CaseInsensitive) && m_view.format_selection->currentIndex() == 1)  dupItem = sizeItem->clone();
+                if ((std.contains("PAL", Qt::CaseInsensitive) && m_profile.frame_rate_num == 25 && m_profile.frame_rate_den == 1) ||
+                    (std.contains("NTSC", Qt::CaseInsensitive) && m_profile.frame_rate_num == 30000 && m_profile.frame_rate_den == 1001))
+                    dupItem = sizeItem->clone();
             } else {
                 dupItem = sizeItem->clone();
             }
 
             if (dupItem) {
                 m_view.size_list->addItem(dupItem);
-                // Make sure the selected profile uses an installed avformat codec / format
                 std = dupItem->data(ParamsRole).toString();
+                // Make sure the selected profile uses the same frame rate as project profile
+                if (std.contains("mlt_profile=")) {
+                    QString profile = std.section("mlt_profile=", 1, 1).section(' ', 0, 0);
+                    MltVideoProfile p = ProfilesDialog::getVideoProfile(profile);
+                    if (p.frame_rate_den > 0) {
+                        double profile_rate = (double) p.frame_rate_num / p.frame_rate_den;
+                        if ((int) (1000.0 * profile_rate) != (int) (1000.0 * project_framerate)) {
+                            dupItem->setToolTip(i18n("Frame rate (%1) not compatible with project profile (%2)", profile_rate, project_framerate));
+                            dupItem->setIcon(brokenIcon);
+                            dupItem->setForeground(disabled);
+                        }
+                    }
+                }
+                
+                // Make sure the selected profile uses an installed avformat codec / format
                 if (!formatsList.isEmpty()) {
                     QString format;
                     if (std.startsWith("f=")) format = std.section("f=", 1, 1);
@@ -1020,7 +1189,7 @@ void RenderWidget::refreshView()
                         if (!formatsList.contains(format)) {
                             kDebug() << "***** UNSUPPORTED F: " << format;
                             //sizeItem->setHidden(true);
-                            //sizeItem->setFlags(Qt::ItemIsSelectable);
+                            //sizeItem-item>setFlags(Qt::ItemIsSelectable);
                             dupItem->setToolTip(i18n("Unsupported video format: %1", format));
                             dupItem->setIcon(brokenIcon);
                             dupItem->setForeground(disabled);
@@ -1060,14 +1229,24 @@ void RenderWidget::refreshView()
                         }
                     }
                 }
+                if (std.contains(" profile=") || std.startsWith("profile=")) {
+                    // changed in MLT commit d8a3a5c9190646aae72048f71a39ee7446a3bd45
+                    // (http://www.mltframework.org/gitweb/mlt.git?p=mltframework.org/mlt.git;a=commit;h=d8a3a5c9190646aae72048f71a39ee7446a3bd45)
+                    dupItem->setToolTip(i18n("This render profile uses a 'profile' parameter.<br />Unless you know what you are doing you will probably have to change it to 'mlt_profile'."));
+                    dupItem->setIcon(warningIcon);
+                }
             }
         }
     }
     // m_view.size_list->sortItems();
     focusFirstVisibleItem();
+    m_view.size_list->setVisible(m_view.size_list->count() > 1 || m_view.format_list->count() <= 1);
     m_view.size_list->blockSignals(false);
     m_view.format_list->blockSignals(false);
-    refreshParams();
+    if (m_view.size_list->count() > 0)
+        refreshParams();
+    else
+        m_view.advanced_params->clear();
 }
 
 KUrl RenderWidget::filenameWithExtension(KUrl url, QString extension)
@@ -1093,10 +1272,6 @@ KUrl RenderWidget::filenameWithExtension(KUrl url, QString extension)
     return KUrl(directory + filename);
 }
 
-
-/**
- * Called when a new format or size has been selected.
- */
 void RenderWidget::refreshParams()
 {
     // Format not available (e.g. codec not installed); Disable start button
@@ -1107,17 +1282,18 @@ void RenderWidget::refreshParams()
         m_view.buttonGenerateScript->setEnabled(false);
         return;
     }
+    errorMessage(item->toolTip());
     QString params = item->data(ParamsRole).toString();
     QString extension = item->data(ExtensionRole).toString();
     m_view.advanced_params->setPlainText(params);
     QString destination = m_view.destination_list->itemData(m_view.destination_list->currentIndex()).toString();
-    if (params.contains(" s=") || destination == "audioonly") {
+    if (params.contains(" s=") || params.startsWith("s=") || destination == "audioonly") {
         // profile has a fixed size, do not allow resize
         m_view.rescale->setEnabled(false);
-        m_view.rescale_size->setEnabled(false);
+        m_view.rescale_box->setEnabled(false);
     } else {
         m_view.rescale->setEnabled(true);
-        m_view.rescale_size->setEnabled(true);
+        m_view.rescale_box->setEnabled(m_view.rescale->isChecked());
     }
     KUrl url = filenameWithExtension(m_view.out_file->url(), extension);
     m_view.out_file->setUrl(url);
@@ -1140,6 +1316,44 @@ void RenderWidget::refreshParams()
         m_view.buttonEdit->setEnabled(true);
     }
 
+    // setup comboBox with bitrates
+    m_view.comboBitrates->clear();
+    if (params.contains("bitrate")) {
+        m_view.comboBitrates->setEnabled(true);
+        m_view.bitrateLabel->setEnabled(true);
+        if ( item->data(BitratesRole).canConvert(QVariant::StringList) && item->data(BitratesRole).toStringList().count()) {
+            QStringList bitrates = item->data(BitratesRole).toStringList();
+            foreach (QString bitrate, bitrates)
+                m_view.comboBitrates->addItem(bitrate);
+            if (item->data(DefaultBitrateRole).canConvert(QVariant::String))
+                m_view.comboBitrates->setCurrentIndex(bitrates.indexOf(item->data(DefaultBitrateRole).toString()));
+        }
+    } else {
+        m_view.comboBitrates->setEnabled(false);
+        m_view.bitrateLabel->setEnabled(false);
+    }
+
+    // setup comboBox with audiobitrates
+    m_view.comboAudioBitrates->clear();
+    if (params.contains("audiobitrate")) {
+        m_view.comboAudioBitrates->setEnabled(true);
+        m_view.audiobitrateLabel->setEnabled(true);
+        if ( item->data(AudioBitratesRole).canConvert(QVariant::StringList) && item->data(AudioBitratesRole).toStringList().count()) {
+            QStringList audiobitrates = item->data(AudioBitratesRole).toStringList();
+            foreach (QString bitrate, audiobitrates)
+                m_view.comboAudioBitrates->addItem(bitrate);
+            if (item->data(DefaultAudioBitrateRole).canConvert(QVariant::String))
+                m_view.comboAudioBitrates->setCurrentIndex(audiobitrates.indexOf(item->data(DefaultAudioBitrateRole).toString()));
+        }
+    } else {
+        m_view.comboAudioBitrates->setEnabled(false);
+        m_view.audiobitrateLabel->setEnabled(false);
+    }
+    
+    m_view.checkTwoPass->setEnabled(params.contains("passes"));
+
+    m_view.encoder_threads->setEnabled(!params.contains("threads="));
+
     m_view.buttonRender->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty());
     m_view.buttonGenerateScript->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty());
 }
@@ -1182,7 +1396,7 @@ void RenderWidget::parseProfiles(QString meta, QString group, QString profile)
     // can also override profiles installed by KNewStuff
     fileList.removeAll("customprofiles.xml");
     foreach(const QString &filename, fileList)
-    parseFile(exportFolder + filename, true);
+        parseFile(exportFolder + filename, true);
     if (QFile::exists(exportFolder + "customprofiles.xml")) parseFile(exportFolder + "customprofiles.xml", true);
 
     if (!meta.isEmpty()) {
@@ -1223,7 +1437,7 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
     QListWidgetItem *item = NULL;
     const QStringList acodecsList = KdenliveSettings::audiocodecs();
     bool replaceVorbisCodec = false;
-    if (!acodecsList.contains("vorbis") && acodecsList.contains("libvorbis")) replaceVorbisCodec = true;
+    if (acodecsList.contains("libvorbis")) replaceVorbisCodec = true;
     bool replaceLibfaacCodec = false;
     if (!acodecsList.contains("aac") && acodecsList.contains("libfaac")) replaceLibfaacCodec = true;
 
@@ -1239,7 +1453,7 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
             newdoc.appendChild(newprofiles);
             QDomNodeList profilelist = doc.elementsByTagName("profile");
             for (int i = 0; i < profilelist.count(); i++) {
-                QString category = i18n("Custom");
+                QString category = i18nc("Category Name", "Custom");
                 QString extension;
                 QDomNode parent = profilelist.at(i).parentNode();
                 if (!parent.isNull()) {
@@ -1284,7 +1498,7 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
                 params = params.replace("aac", "libfaac");
             }
 
-            QString category = profile.attribute("category", i18n("Custom"));
+            QString category = profile.attribute("category", i18nc("Category Name", "Custom"));
             QString dest = profile.attribute("destinationid");
             QString prof_extension = profile.attribute("extension");
             if (!prof_extension.isEmpty()) extension = prof_extension;
@@ -1322,6 +1536,10 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
             item->setData(RenderRole, "avformat");
             item->setData(StandardRole, standard);
             item->setData(ParamsRole, params);
+            item->setData(BitratesRole, profile.attribute("bitrates").split(',', QString::SkipEmptyParts));
+            item->setData(DefaultBitrateRole, profile.attribute("defaultbitrate"));
+            item->setData(AudioBitratesRole, profile.attribute("audiobitrates").split(',', QString::SkipEmptyParts));
+            item->setData(DefaultAudioBitrateRole, profile.attribute("defaultaudiobitrate"));
             if (profile.hasAttribute("url")) item->setData(ExtraRole, profile.attribute("url"));
             if (editable) {
                 item->setData(EditableRole, exportFile);
@@ -1343,6 +1561,7 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
     QString renderer;
     QString params;
     QString standard;
+    QString bitrates, defaultBitrate, audioBitrates, defaultAudioBitrate;
     KIcon icon;
 
     while (!groups.item(i).isNull()) {
@@ -1364,7 +1583,7 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
                 m_view.destination_list->addItem(icon, i18n(metagroupName.toUtf8().data()), metagroupId);
             }
         }
-        groupName = documentElement.attribute("name", i18n("Custom"));
+        groupName = documentElement.attribute("name", i18nc("Attribute Name", "Custom"));
         extension = documentElement.attribute("extension", QString());
         renderer = documentElement.attribute("renderer", QString());
         bool exists = false;
@@ -1389,6 +1608,10 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
             profileElement = n.toElement();
             profileName = profileElement.attribute("name");
             standard = profileElement.attribute("standard");
+            bitrates = profileElement.attribute("bitrates");
+            defaultBitrate = profileElement.attribute("defaultbitrate");
+            audioBitrates = profileElement.attribute("audiobitrates");
+            defaultAudioBitrate = profileElement.attribute("defaultaudiobitrate");
             params = profileElement.attribute("args");
 
             if (replaceVorbisCodec && params.contains("acodec=vorbis")) {
@@ -1409,6 +1632,10 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
             item->setData(RenderRole, renderer);
             item->setData(StandardRole, standard);
             item->setData(ParamsRole, params);
+            item->setData(BitratesRole, bitrates.split(',', QString::SkipEmptyParts));
+            item->setData(DefaultBitrateRole, defaultBitrate);
+            item->setData(AudioBitratesRole, audioBitrates.split(',', QString::SkipEmptyParts));
+            item->setData(DefaultAudioBitrateRole, defaultAudioBitrate);
             if (profileElement.hasAttribute("url")) item->setData(ExtraRole, profileElement.attribute("url"));
             if (editable) item->setData(EditableRole, exportFile);
             m_renderItems.append(item);
@@ -1530,6 +1757,12 @@ void RenderWidget::slotCheckJob()
         activate = true;
     }
     m_view.abort_job->setEnabled(activate);
+    for (int i = 0; i < m_view.running_jobs->topLevelItemCount(); i++) {
+        current = m_view.running_jobs->topLevelItem(i);
+        if (current == m_view.running_jobs->currentItem()) {
+            current->setSizeHint(1, QSize(m_view.running_jobs->columnWidth(1), fontMetrics().height() * 3));
+        } else current->setSizeHint(1, QSize(m_view.running_jobs->columnWidth(1), fontMetrics().height() * 2));
+    }
 }
 
 void RenderWidget::slotCLeanUpJobs()
@@ -1561,17 +1794,18 @@ void RenderWidget::parseScriptFiles()
         QString melt;
         QFile file(scriptpath.path());
         if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
-            while (!file.atEnd()) {
-                QByteArray line = file.readLine();
+            QTextStream stream(&file);
+            while (!stream.atEnd()) {
+                QString line = stream.readLine();
                 if (line.startsWith("TARGET=")) {
-                    target = QString(line).section("TARGET=", 1).simplified();
-                    target.remove(QChar('"'));
-                } else if (line.startsWith("RENDERER=")) {
-                    renderer = QString(line).section("RENDERER=", 1).simplified();
-                    renderer.remove(QChar('"'));
-                } else if (line.startsWith("MELT=")) {
-                    melt = QString(line).section("MELT=", 1).simplified();
-                    melt.remove(QChar('"'));
+                    target = line.section("TARGET=\"", 1);
+                    target = target.section('"', 0, 0);
+                } else if (line.startsWith("RENDERER=\"")) {
+                    renderer = line.section("RENDERER=", 1);
+                    renderer = renderer.section('"', 0, 0);
+                } else if (line.startsWith("MELT=\"")) {
+                    melt = line.section("MELT=", 1);
+                    melt = melt.section('"', 0, 0);
                 }
             }
             file.close();
@@ -1588,15 +1822,15 @@ void RenderWidget::parseScriptFiles()
             item->setData(0, Qt::UserRole, '1');
         } else item->setIcon(0, KIcon("application-x-executable-script"));
         item->setSizeHint(0, QSize(m_view.scripts_list->columnWidth(0), fontMetrics().height() * 2));
-        item->setData(1, Qt::UserRole, target.simplified());
+        item->setData(1, Qt::UserRole, KUrl(target).path());
         item->setData(1, Qt::UserRole + 1, scriptpath.path());
     }
-    bool activate = false;
+//     bool activate = false;
     QTreeWidgetItem *script = m_view.scripts_list->topLevelItem(0);
     if (script) {
-        script->setSelected(true);
         m_view.scripts_list->setCurrentItem(script);
-        activate = true;
+        script->setSelected(true);
+//         activate = true;
     }
 //    m_view.start_script->setEnabled(activate);
 //    m_view.delete_script->setEnabled(activate);
@@ -1604,10 +1838,16 @@ void RenderWidget::parseScriptFiles()
 
 void RenderWidget::slotCheckScript()
 {
-    QTreeWidgetItem *item = m_view.scripts_list->currentItem();
-    if (item == NULL) return;
-    m_view.start_script->setEnabled(item->data(0, Qt::UserRole).toString().isEmpty());
+    QTreeWidgetItem *current = m_view.scripts_list->currentItem();
+    if (current == NULL) return;
+    m_view.start_script->setEnabled(current->data(0, Qt::UserRole).toString().isEmpty());
     m_view.delete_script->setEnabled(true);
+    for (int i = 0; i < m_view.scripts_list->topLevelItemCount(); i++) {
+        current = m_view.scripts_list->topLevelItem(i);
+        if (current == m_view.scripts_list->currentItem()) {
+            current->setSizeHint(1, QSize(m_view.scripts_list->columnWidth(1), fontMetrics().height() * 3));
+        } else current->setSizeHint(1, QSize(m_view.scripts_list->columnWidth(1), fontMetrics().height() * 2));
+    }
 }
 
 void RenderWidget::slotStartScript()
@@ -1662,16 +1902,45 @@ void RenderWidget::slotHideLog()
     m_view.error_box->setVisible(false);
 }
 
-void RenderWidget::setRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &url)
+void RenderWidget::setRenderProfile(QMap <QString, QString> props)
 {
     m_view.destination_list->blockSignals(true);
     m_view.format_list->blockSignals(true);
-
+    m_view.scanning_list->setCurrentIndex(props.value("renderscanning").toInt());
+    int exportAudio = props.value("renderexportaudio").toInt();
+    switch (exportAudio) {
+    case 1:
+        m_view.export_audio->setCheckState(Qt::Unchecked);
+        break;
+    case 2:
+        m_view.export_audio->setCheckState(Qt::Checked);
+        break;
+    default:
+        m_view.export_audio->setCheckState(Qt::PartiallyChecked);
+    }
+    if (props.contains("renderrescale")) m_view.rescale->setChecked(props.value("renderrescale").toInt());
+    if (props.contains("renderrescalewidth")) m_view.rescale_width->setValue(props.value("renderrescalewidth").toInt());
+    if (props.contains("renderrescaleheight")) m_view.rescale_height->setValue(props.value("renderrescaleheight").toInt());
+    if (props.contains("rendertcoverlay")) m_view.tc_overlay->setChecked(props.value("rendertcoverlay").toInt());
+    if (props.contains("rendertctype")) m_view.tc_type->setCurrentIndex(props.value("rendertctype").toInt());
+    if (props.contains("renderratio")) m_view.rescale_keep->setChecked(props.value("renderratio").toInt());
+    if (props.contains("renderplay")) m_view.play_after->setChecked(props.value("renderplay").toInt());
+    if (props.contains("rendertwopass")) m_view.checkTwoPass->setChecked(props.value("rendertwopass").toInt());
+
+    if (props.value("renderzone") == "1") m_view.render_zone->setChecked(true);
+    else if (props.value("renderguide") == "1") {
+        m_view.render_guide->setChecked(true);
+        m_view.guide_start->setCurrentIndex(props.value("renderstartguide").toInt());
+        m_view.guide_end->setCurrentIndex(props.value("renderendguide").toInt());
+    } else m_view.render_full->setChecked(true);
+    slotUpdateGuideBox();
+
+    QString url = props.value("renderurl");
     if (!url.isEmpty()) m_view.out_file->setUrl(KUrl(url));
 
     // set destination
     for (int i = 0; i < m_view.destination_list->count(); i++) {
-        if (m_view.destination_list->itemData(i, Qt::UserRole) == dest) {
+        if (m_view.destination_list->itemData(i, Qt::UserRole) == props.value("renderdestination")) {
             m_view.destination_list->setCurrentIndex(i);
             break;
         }
@@ -1679,18 +1948,21 @@ void RenderWidget::setRenderProfile(const QString &dest, const QString &group, c
     refreshCategory();
 
     // set category
+    QString group = props.value("rendercategory");
     if (!group.isEmpty()) {
         QList<QListWidgetItem *> childs = m_view.format_list->findItems(group, Qt::MatchExactly);
         if (!childs.isEmpty()) {
             m_view.format_list->setCurrentItem(childs.at(0));
+            m_view.format_list->scrollToItem(childs.at(0));
         }
         refreshView();
     }
 
     // set profile
-    QList<QListWidgetItem *> childs = m_view.size_list->findItems(name, Qt::MatchExactly);
+    QList<QListWidgetItem *> childs = m_view.size_list->findItems(props.value("renderprofile"), Qt::MatchExactly);
     if (!childs.isEmpty()) {
         m_view.size_list->setCurrentItem(childs.at(0));
+        m_view.size_list->scrollToItem(childs.at(0));
     }
     //refreshView();
     m_view.destination_list->blockSignals(false);
@@ -1755,10 +2027,98 @@ QString RenderWidget::getFreeScriptName(const QString &prefix)
 void RenderWidget::slotPlayRendering(QTreeWidgetItem *item, int)
 {
     if (KdenliveSettings::defaultplayerapp().isEmpty() || item->data(1, Qt::UserRole + 2).toInt() != FINISHEDJOB) return;
-    const QByteArray startId = KStartupInfo::createNewStartupId();
-    const QString command = KdenliveSettings::defaultplayerapp() + ' ' + item->text(1);
-    KRun::runCommand(command, KdenliveSettings::defaultplayerapp(), KdenliveSettings::defaultplayerapp(), this, startId);
+    KUrl::List urls;
+    urls.append(KUrl(item->text(1)));
+    KRun::run(KdenliveSettings::defaultplayerapp(), urls, this);
+}
+
+void RenderWidget::missingClips(bool hasMissing)
+{
+    if (hasMissing) {
+        m_view.errorLabel->setText(i18n("Check missing clips"));
+        m_view.errorBox->setHidden(false);
+    } else m_view.errorBox->setHidden(true);
+}
+
+void RenderWidget::errorMessage(const QString &message)
+{
+    if (!message.isEmpty()) {
+#if KDE_IS_VERSION(4,7,0)
+        m_infoMessage->setMessageType(KMessageWidget::Warning);
+        m_infoMessage->setText(message);
+        m_infoMessage->animatedShow();
+#else
+        m_view.errorLabel->setText(message);
+        m_view.errorBox->setHidden(false);
+#endif
+    }
+    else {
+#if KDE_IS_VERSION(4,7,0)
+        m_infoMessage->animatedHide();
+#else
+        m_view.errorBox->setHidden(true);
+        m_view.errorLabel->setText(QString());
+#endif
+
+    }
+}
+
+
+void RenderWidget::slotUpdateEncodeThreads(int val)
+{
+       KdenliveSettings::setEncodethreads(val);
+}
+
+void RenderWidget::slotUpdateRescaleWidth(int val)
+{
+    KdenliveSettings::setDefaultrescalewidth(val);
+    if (!m_view.rescale_keep->isChecked()) return;
+    m_view.rescale_height->blockSignals(true);
+    m_view.rescale_height->setValue(val * m_profile.height / m_profile.width  + 0.5);
+    KdenliveSettings::setDefaultrescaleheight(m_view.rescale_height->value());
+    m_view.rescale_height->blockSignals(false);
+}
+
+void RenderWidget::slotUpdateRescaleHeight(int val)
+{
+    KdenliveSettings::setDefaultrescaleheight(val);
+    if (!m_view.rescale_keep->isChecked()) return;
+    m_view.rescale_width->blockSignals(true);
+    m_view.rescale_width->setValue(val * m_profile.width / m_profile.height + 0.5);
+    KdenliveSettings::setDefaultrescaleheight(m_view.rescale_width->value());
+    m_view.rescale_width->blockSignals(false);
+}
+
+void RenderWidget::slotSwitchAspectRatio()
+{
+    KdenliveSettings::setRescalekeepratio(m_view.rescale_keep->isChecked());
+    if (m_view.rescale_keep->isChecked()) slotUpdateRescaleWidth(m_view.rescale_width->value());
 }
 
+void RenderWidget::slotUpdateAudioLabel(int ix)
+{
+    if (ix == Qt::PartiallyChecked)
+        m_view.export_audio->setText(i18n("Export audio (automatic)"));
+    else
+        m_view.export_audio->setText(i18n("Export audio"));
+}
+
+bool RenderWidget::automaticAudioExport() const
+{
+    return (m_view.export_audio->checkState() == Qt::PartiallyChecked);
+}
+
+bool RenderWidget::selectedAudioExport() const
+{
+    return (m_view.export_audio->checkState() != Qt::Unchecked);
+}
 
+void RenderWidget::updateProxyConfig(bool enable)
+{
+    m_view.proxy_render->setHidden(!enable);
+}
 
+bool RenderWidget::proxyRendering()
+{
+    return m_view.proxy_render->isChecked();
+}