#include "kdenlivesettings.h"
#include "ui_saveprofile_ui.h"
#include "timecode.h"
+#include "profilesdialog.h"
#include <KStandardDirs>
#include <KDebug>
#include <QDBusConnectionInterface>
#include <QDBusInterface>
#include <QThread>
+#include <QScriptEngine>
const int GroupRole = Qt::UserRole;
const int ExtensionRole = GroupRole + 1;
const int EditableRole = GroupRole + 5;
const int MetaGroupRole = GroupRole + 6;
const int ExtraRole = GroupRole + 7;
-const int TwoPassRole = GroupRole + 8;
+const int BitratesRole = GroupRole + 8;
+const int DefaultBitrateRole = GroupRole + 9;
// Running job status
const int WAITINGJOB = 0;
m_view.proxy_render->setHidden(!enableProxy);
- 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.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)));
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);
}
}
-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();
if (!scriptExport) render_process_args << "-erase";
if (KdenliveSettings::usekuiserver()) render_process_args << "-kuiserver";
+ // 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;
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 << "-";
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));
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");
-
// Check if the rendering profile is different from project profile,
// in which case we need to use the producer_comsumer from MLT
QString std = renderArgs;
}
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("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:" + (scriptExport ? "$SOURCE" : playlistPath);
else
outStream << "SOURCE=" << "\"" + playlistPath + "\"" << "\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();
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);
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()) {
}
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;
if (m_view.destination_list->currentIndex() > 0)
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);
+ KIcon warningIcon("dialog-warning");
const QStringList formatsList = KdenliveSettings::supportedformats();
const QStringList vcodecsList = KdenliveSettings::videocodecs();
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);
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);
}
}
}
+ 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)
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);
m_view.buttonEdit->setEnabled(true);
}
+ // setup comboBox with bitrates
+ m_view.comboBitrates->clear();
+ if (params.contains("bitrate")) {
+ m_view.comboBitrates->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.checkTwoPass->setEnabled(params.contains("passes"));
+
m_view.buttonRender->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty());
m_view.buttonGenerateScript->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty());
}
QString renderer;
QString params;
QString standard;
- QString twoPass;
+ QString bitrates, defaultBitrate;
KIcon icon;
while (!groups.item(i).isNull()) {
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) {
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);
}
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")) {
item->setData(RenderRole, renderer);
item->setData(StandardRole, standard);
item->setData(ParamsRole, params);
+ item->setData(BitratesRole, bitrates.split(',', QString::SkipEmptyParts));
+ item->setData(DefaultBitrateRole, defaultBitrate);
if (profileElement.hasAttribute("url")) item->setData(ExtraRole, profileElement.attribute("url"));
if (editable) item->setData(EditableRole, exportFile);
m_renderItems.append(item);
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) {
m_view.scripts_list->setCurrentItem(script);
script->setSelected(true);
- activate = true;
+// activate = true;
}
// m_view.start_script->setEnabled(activate);
// m_view.delete_script->setEnabled(activate);
} else m_view.errorBox->setHidden(true);
}
+void RenderWidget::errorMessage(const QString &message)
+{
+ if (!message.isEmpty()) {
+ m_view.errorLabel->setText(message);
+ m_view.errorBox->setHidden(false);
+ }
+ else {
+ m_view.errorBox->setHidden(true);
+ m_view.errorLabel->setText(QString());
+ }
+}
+
+
void RenderWidget::slotUpdateEncodeThreads(int val)
{
KdenliveSettings::setEncodethreads(val);