X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Frenderwidget.cpp;h=e5e2f561ce64d4430138069081f2f9b351762e7c;hb=96b6bac33fc676599014cf64747318a2833dd499;hp=6a43e9291594a17ed89af766683e7fbacbfa89c6;hpb=5d2a663632df09f4b04acf0aeb0406ea51c8543d;p=kdenlive diff --git a/src/renderwidget.cpp b/src/renderwidget.cpp index 6a43e929..e5e2f561 100644 --- a/src/renderwidget.cpp +++ b/src/renderwidget.cpp @@ -53,6 +53,9 @@ const int ParamsRole = GroupRole + 4; const int EditableRole = GroupRole + 5; const int MetaGroupRole = GroupRole + 6; const int ExtraRole = GroupRole + 7; +const int TwoPassRole = GroupRole + 8; +const int BitratesRole = GroupRole + 9; +const int DefaultBitrateRole = GroupRole + 10; // Running job status const int WAITINGJOB = 0; @@ -83,6 +86,8 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg 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); @@ -174,6 +179,7 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg 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); @@ -754,6 +760,8 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const 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"); @@ -762,9 +770,17 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const // disable audio if requested if (!exportAudio) renderArgs.append(" an=1 "); - // Set the thread counts - renderArgs.append(QString(" threads=%1").arg(KdenliveSettings::encodethreads())); - renderArgs.append(QString(" real_time=-%1").arg(KdenliveSettings::mltthreads())); + // Set the thread counts + renderArgs.append(QString(" threads=%1").arg(KdenliveSettings::encodethreads())); + renderArgs.append(QString(" real_time=-%1").arg(KdenliveSettings::mltthreads())); + + // 2 pass + if (m_view.checkTwoPass->isEnabled() && m_view.checkTwoPass->isChecked()) + renderArgs.append(" pass=2"); + + // bitrate + if (m_view.comboBitrates->isEnabled()) + renderArgs.replace("%bitrate", m_view.comboBitrates->currentText()); // Check if the rendering profile is different from project profile, // in which case we need to use the producer_comsumer from MLT @@ -796,16 +812,11 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const render_process_args << "consumer:" + (scriptExport ? "$SOURCE" : playlistPath); else render_process_args << (scriptExport ? "$SOURCE" : playlistPath); - render_process_args << (scriptExport ? "$TARGET" : dest); + 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 @@ -817,7 +828,7 @@ 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 << "PARAMETERS=" << "\"" + render_process_args.join(" ") + "\"" << "\n"; @@ -834,7 +845,6 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const m_view.tabWidget->setCurrentIndex(2); return; } - renderParameters << scriptName; // Save rendering profile to document QMap renderProps; @@ -859,6 +869,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const 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); @@ -968,8 +979,10 @@ 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); + 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()) { @@ -1050,6 +1063,11 @@ void RenderWidget::refreshView() destination = m_view.destination_list->itemData(m_view.destination_list->currentIndex()).toString(); KIcon brokenIcon("dialog-close"); + if (m_view.format_list->currentItem()->data(TwoPassRole).canConvert(QVariant::Bool)) + m_view.checkTwoPass->setEnabled(m_view.format_list->currentItem()->data(TwoPassRole).toBool()); + else + m_view.checkTwoPass->setEnabled(true); + const QStringList formatsList = KdenliveSettings::supportedformats(); const QStringList vcodecsList = KdenliveSettings::videocodecs(); const QStringList acodecsList = KdenliveSettings::audiocodecs(); @@ -1200,6 +1218,19 @@ void RenderWidget::refreshParams() m_view.buttonEdit->setEnabled(true); } + // setup comboBox with bitrates + if (item->data(BitratesRole).canConvert(QVariant::StringList)) { + m_view.comboBitrates->setEnabled(true); + m_view.comboBitrates->clear(); + 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.buttonRender->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty()); m_view.buttonGenerateScript->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty()); } @@ -1403,6 +1434,8 @@ void RenderWidget::parseFile(QString exportFile, bool editable) QString renderer; QString params; QString standard; + QString twoPass; + QString bitrates, defaultBitrate; KIcon icon; while (!groups.item(i).isNull()) { @@ -1427,6 +1460,7 @@ void RenderWidget::parseFile(QString exportFile, bool editable) groupName = documentElement.attribute("name", i18nc("Attribute Name", "Custom")); extension = documentElement.attribute("extension", QString()); renderer = documentElement.attribute("renderer", QString()); + twoPass = documentElement.attribute("twopass", "true"); bool exists = false; for (int j = 0; j < m_renderCategory.count(); j++) { if (m_renderCategory.at(j)->text() == groupName && m_renderCategory.at(j)->data(MetaGroupRole) == metagroupId) { @@ -1437,6 +1471,7 @@ void RenderWidget::parseFile(QString exportFile, bool editable) if (!exists) { QListWidgetItem *itemcat = new QListWidgetItem(groupName); //, m_view.format_list); itemcat->setData(MetaGroupRole, metagroupId); + itemcat->setData(TwoPassRole, twoPass == "false" ? false : true); m_renderCategory.append(itemcat); } @@ -1449,6 +1484,8 @@ 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"); params = profileElement.attribute("args"); if (replaceVorbisCodec && params.contains("acodec=vorbis")) { @@ -1469,6 +1506,8 @@ void RenderWidget::parseFile(QString exportFile, bool editable) item->setData(RenderRole, renderer); item->setData(StandardRole, standard); item->setData(ParamsRole, params); + item->setData(BitratesRole, bitrates.split(',')); + item->setData(DefaultBitrateRole, defaultBitrate); if (profileElement.hasAttribute("url")) item->setData(ExtraRole, profileElement.attribute("url")); if (editable) item->setData(EditableRole, exportFile); m_renderItems.append(item); @@ -1631,14 +1670,14 @@ void RenderWidget::parseScriptFiles() while (!stream.atEnd()) { QString line = stream.readLine(); if (line.startsWith("TARGET=")) { - target = line.section("TARGET=", 1).simplified(); - target.remove(QChar('"')); - } else if (line.startsWith("RENDERER=")) { - renderer = line.section("RENDERER=", 1).simplified(); - renderer.remove(QChar('"')); - } else if (line.startsWith("MELT=")) { - melt = 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(); @@ -1655,7 +1694,7 @@ 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; @@ -1758,6 +1797,7 @@ void RenderWidget::setRenderProfile(QMap props) 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") { @@ -1859,9 +1899,9 @@ 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)