Commit aa0ee902 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix transcoding to correctly adjust to audio/video only transcode when...

Fix transcoding to correctly adjust to audio/video only transcode when required, adjust button text to inform user
parent 4ce228b2
Pipeline #150126 passed with stage
in 9 minutes and 32 seconds
......@@ -4867,16 +4867,17 @@ void Bin::requestTranscoding(const QString &url, const QString &id, int type, bo
}
});
}
if (url.isEmpty()) {
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(id);
if (clip) {
QString resource = clip->clipUrl();
m_transcodingDialog->addUrl(resource, id, suffix, (ClipType::ProducerType) type, message);
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(id);
if (clip) {
ClipType::ProducerType cType = (ClipType::ProducerType)type;
if (cType == ClipType::Unknown) {
cType = clip->clipType();
}
} else {
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(id);
if (clip) {
m_transcodingDialog->addUrl(url, id, suffix, (ClipType::ProducerType) type, message);
if (url.isEmpty()) {
QString resource = clip->clipUrl();
m_transcodingDialog->addUrl(resource, id, suffix, cType, message);
} else {
m_transcodingDialog->addUrl(url, id, suffix, cType, message);
}
}
m_transcodingDialog->show();
......
......@@ -1578,8 +1578,7 @@ TimeRemap::TimeRemap(QWidget *parent)
QAction *ac = new QAction(i18n("Transcode"), this);
warningMessage->addAction(ac);
connect(ac, &QAction::triggered, this, [&]() {
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, QString()), Q_ARG(QString, m_binId), Q_ARG(bool, false));
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, QString()), Q_ARG(QString, m_binId), Q_ARG(int, 0), Q_ARG(bool, false));
});
m_in = new TimecodeDisplay(pCore->timecode(), this);
inLayout->addWidget(m_in);
......
......@@ -492,6 +492,8 @@ void ClipLoadTask::run()
cType = ClipType::Audio;
} else if (producer->get_int("audio_index") == -1) {
cType = ClipType::Video;
} else {
cType = ClipType::AV;
}
}
producer.reset();
......@@ -633,6 +635,8 @@ void ClipLoadTask::run()
cType = ClipType::Audio;
} else if (!hasAudio) {
cType = ClipType::Video;
} else {
cType = ClipType::AV;
}
}
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, QString::number(m_owner.second)), Q_ARG(int, cType), Q_ARG(bool, checkProfile), Q_ARG(QString, QString()), Q_ARG(QString, i18n("File <b>%1</b> is not seekable.", QFileInfo(resource).fileName())));
......@@ -676,6 +680,8 @@ void ClipLoadTask::run()
cType = ClipType::Audio;
} else if (!hasAudio) {
cType = ClipType::Video;
} else {
cType = ClipType::AV;
}
}
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, QString::number(m_owner.second)), Q_ARG(int, cType), Q_ARG(bool, checkProfile), Q_ARG(QString, adjustedFpsString), Q_ARG(QString, i18n("File <b>%1</b> has a variable frame rate.", QFileInfo(resource).fileName())));
......
......@@ -208,7 +208,7 @@ void TranscodeTask::run()
parameters << t;
}
}
qDebug()<<"/// FULL PROXY PARAMS:\n"<<parameters<<"\n------";
qDebug()<<"/// FULL TRANSCODE PARAMS:\n"<<parameters<<"\n------";
m_jobProcess.reset(new QProcess);
// m_jobProcess->setProcessChannelMode(QProcess::MergedChannels);
QObject::connect(this, &TranscodeTask::jobCanceled, m_jobProcess.get(), &QProcess::kill, Qt::DirectConnection);
......@@ -233,10 +233,14 @@ void TranscodeTask::run()
QMap <QString, QString> sourceProps;
QMap <QString, QString> newProps;
sourceProps.insert(QStringLiteral("resource"), binClip->url());
sourceProps.insert(QStringLiteral("kdenlive:originalurl"), binClip->url());
sourceProps.insert(QStringLiteral("kdenlive:proxy"), binClip->getProducerProperty(QStringLiteral("kdenlive:proxy")));
sourceProps.insert(QStringLiteral("kdenlive:clipname"), binClip->clipName());
sourceProps.insert(QStringLiteral("_fullreload"), QStringLiteral("1"));
newProps.insert(QStringLiteral("resource"), destUrl);
newProps.insert(QStringLiteral("kdenlive:originalurl"), destUrl);
newProps.insert(QStringLiteral("kdenlive:clipname"), QFileInfo(destUrl).fileName());
newProps.insert(QStringLiteral("kdenlive:proxy"), QString());
newProps.insert(QStringLiteral("_fullreload"), QStringLiteral("1"));
pCore->bin()->slotEditClipCommand(binClip->clipId(), sourceProps, newProps);
if (m_checkProfile) {
......
......@@ -1004,7 +1004,7 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
m_warningMessage.setText(i18n("File uses a variable frame rate, not recommended"));
QAction *ac = new QAction(i18n("Transcode"));
QObject::connect(ac, &QAction::triggered, [id = m_id, resource = controller->clipUrl()]() {
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, id), Q_ARG(bool, false));
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, id), Q_ARG(int, 0), Q_ARG(bool, false));
});
m_warningMessage.setMessageType(KMessageWidget::Warning);
m_warningMessage.addAction(ac);
......
......@@ -13,6 +13,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include <KMessageBox>
#include <QFontDatabase>
#include <QStandardPaths>
#include <QPushButton>
#include <klocalizedstring.h>
TranscodeSeek::TranscodeSeek(QWidget *parent)
......@@ -26,10 +27,28 @@ TranscodeSeek::TranscodeSeek(QWidget *parent)
KConfigGroup group(&conf, "intermediate");
m_encodeParams = group.entryMap();
encodingprofiles->addItems(group.keyList());
connect(encodingprofiles, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [&](int ix) {
const QString currentParams = m_encodeParams.value(encodingprofiles->itemText(ix));
if (currentParams.endsWith(QLatin1String(";audio"))) {
buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Audio transcode"));
} else if (currentParams.endsWith(QLatin1String(";video"))) {
buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Video transcode"));
} else {
buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Transcode"));
}
});
int ix = encodingprofiles->findText(KdenliveSettings::transcodeFriendly());
if (ix > -1) {
encodingprofiles->setCurrentIndex(ix);
}
const QString currentParams = m_encodeParams.value(encodingprofiles->currentText());
if (currentParams.endsWith(QLatin1String(";audio"))) {
buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Audio transcode"));
} else if (currentParams.endsWith(QLatin1String(";video"))) {
buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Video transcode"));
} else {
buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Transcode"));
}
autorotate->setChecked(KdenliveSettings::transcodeFriendlyRotate());
messagewidget->setVisible(false);
}
......@@ -58,9 +77,11 @@ void TranscodeSeek::addUrl(const QString &file, const QString &id, const QString
}
}
}
const QString currentParams = m_encodeParams.value(encodingprofiles->currentText());
if (listWidget->count() == 1) {
QString currentParams = m_encodeParams.value(encodingprofiles->currentText());
if (type == ClipType::Audio) {
if (!m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";audio"))) {
if (!currentParams.endsWith(QLatin1String(";audio"))) {
// Switch to audio only profile
QMapIterator<QString, QString> i(m_encodeParams);
while (i.hasNext()) {
......@@ -75,7 +96,7 @@ void TranscodeSeek::addUrl(const QString &file, const QString &id, const QString
}
}
} else if (type == ClipType::Video) {
if (!m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";video"))) {
if (!currentParams.endsWith(QLatin1String(";video"))) {
// Switch to video only profile
QMapIterator<QString, QString> i(m_encodeParams);
while (i.hasNext()) {
......@@ -91,7 +112,7 @@ void TranscodeSeek::addUrl(const QString &file, const QString &id, const QString
}
}
} else {
if ((type != ClipType::Video && m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";video"))) || (type != ClipType::Audio && m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";audio")))) {
if ((type != ClipType::Video && currentParams.endsWith(QLatin1String(";video"))) || (type != ClipType::Audio && currentParams.endsWith(QLatin1String(";audio")))) {
// Switch back to an AV profile
QMapIterator<QString, QString> i(m_encodeParams);
while (i.hasNext()) {
......
Supports Markdown
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