Fix various transcoding issues

CCBUG: 407808
parent 1ca29700
Pipeline #3747 passed with stage
in 19 minutes and 17 seconds
......@@ -1519,7 +1519,7 @@ void Bin::contextMenuEvent(QContextMenuEvent *event)
m_inTimelineAction->setVisible(itemType != AbstractProjectItem::FolderItem);
if (m_transcodeAction) {
m_transcodeAction->setEnabled(enableClipActions);
m_transcodeAction->menuAction()->setVisible(itemType != AbstractProjectItem::FolderItem && clipService.contains(QStringLiteral("avformat")));
m_transcodeAction->menuAction()->setVisible(itemType != AbstractProjectItem::FolderItem && (type == ClipType::Playlist || ClipType::Text || clipService.contains(QStringLiteral("avformat"))));
}
m_clipsActionsMenu->menuAction()->setVisible(
itemType != AbstractProjectItem::FolderItem &&
......
......@@ -83,21 +83,28 @@ bool TranscodeJob::startJob()
// change FFmpeg params to MLT format
m_isFfmpegJob = false;
// insert transcoded filename
m_transcodeParams.replace(QStringLiteral("%1"), QString("-consumer avformat:%1").arg(m_destUrl));
m_transcodeParams.replace(QStringLiteral("%1"), QString("-consumer %1"));
// Convert param style
QStringList params = m_transcodeParams.split(QLatin1Char('-'), QString::SkipEmptyParts);
bool skipNext = false;
QStringList mltParameters;
for (const QString &s : params) {
QString t = s.simplified();
if (skipNext) {
skipNext = false;
continue;
}
if (t.count(QLatin1Char(' ')) == 0) {
t.append(QLatin1String("=1"));
} else {
t.replace(QLatin1Char(' '), QLatin1String("="));
if (t.contains(QLatin1String("%1"))) {
// file name
mltParameters.prepend(t.section(QLatin1Char(' '), 1).replace(QLatin1String("%1"), QString("avformat:%1").arg(m_destUrl)));
mltParameters.prepend(QStringLiteral("-consumer"));
continue;
}
if (t.startsWith(QLatin1String("aspect "))) {
// Fix aspect ratio calculation
t.replace(QLatin1Char(' '), QLatin1String("=@"));
t.replace(QLatin1Char(':'), QLatin1String("/"));
} else {
t.replace(QLatin1Char(' '), QLatin1String("="));
}
}
mltParameters << t;
}
......@@ -111,8 +118,8 @@ bool TranscodeJob::startJob()
mltParameters.append(QStringLiteral("threads=%1").arg(threadCount));
// Ask for progress reporting
mltParameters << QStringLiteral("progress=1") << QStringLiteral("-consumer")<<QString("avformat:%1").arg(m_destUrl);
mltParameters << QStringLiteral("progress=1");
mltParameters.prepend(source);
m_jobProcess = new QProcess;
// m_jobProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(this, &TranscodeJob::jobCanceled, m_jobProcess, &QProcess::kill, Qt::DirectConnection);
......@@ -134,12 +141,15 @@ bool TranscodeJob::startJob()
parameters << QStringLiteral("-stats") << QStringLiteral("-i") << source;
// Only output error data
parameters << QStringLiteral("-v") << QStringLiteral("error");
m_transcodeParams.replace(QStringLiteral("%1"), m_destUrl);
QStringList params = m_transcodeParams.split(QLatin1Char(' '));
QStringList finalParams{QStringLiteral("-i"),source};
for (const QString &s : params) {
QString t = s.simplified();
parameters << t;
if (t.startsWith(QLatin1String("%1"))) {
parameters << t.replace(QLatin1String("%1"), m_destUrl);
} else {
parameters << t;
}
}
qDebug()<<"/// FULL PROXY PARAMS:\n"<<parameters<<"\n------";
m_jobProcess = new QProcess;
......
......@@ -157,11 +157,8 @@ void ClipTranscode::slotStartTransCode()
}
QString extension = params.section(QStringLiteral("%1"), 1, 1).section(QLatin1Char(' '), 0, 0);
QString s_url = source_url->url().toLocalFile();
if (params.contains(QLatin1String("-i "))) {
// Filename must be inserted later
} else {
parameters << QStringLiteral("-i") << s_url;
}
bool mltEncoding = s_url.endsWith(QLatin1String(".mlt")) || s_url.endsWith(QLatin1String(".kdenlive"));
if (QFile::exists(destination + extension)) {
if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", destination + extension)) == KMessageBox::No) {
// Abort operation
......@@ -172,7 +169,48 @@ void ClipTranscode::slotStartTransCode()
}
return;
}
parameters << QStringLiteral("-y");
if (!mltEncoding) {
parameters << QStringLiteral("-y");
}
}
if (mltEncoding) {
params.replace(QStringLiteral("%1"), QString("-consumer %1"));
const QStringList splitted = params.split(QLatin1Char('-'), QString::SkipEmptyParts);
for (const QString &s : splitted) {
QString t = s.simplified();
if (t.count(QLatin1Char(' ')) == 0) {
t.append(QLatin1String("=1"));
} else {
if (t.contains(QLatin1String("%1"))) {
// file name
parameters.prepend(t.section(QLatin1Char(' '), 1).replace(QLatin1String("%1"), QString("avformat:%1").arg(destination)));
parameters.prepend(QStringLiteral("-consumer"));
continue;
}
if (t.startsWith(QLatin1String("aspect "))) {
// Fix aspect ratio calculation
t.replace(QLatin1Char(' '), QLatin1String("=@"));
t.replace(QLatin1Char(':'), QLatin1String("/"));
} else {
t.replace(QLatin1Char(' '), QLatin1String("="));
}
}
parameters << t;
}
parameters.prepend(s_url);
buttonBox->button(QDialogButtonBox::Abort)->setText(i18n("Abort"));
m_destination = destination + extension;
m_transcodeProcess.start(KdenliveSettings::rendererpath(), parameters);
source_url->setEnabled(false);
dest_url->setEnabled(false);
button_start->setEnabled(false);
return;
}
if (params.contains(QLatin1String("-i "))) {
// Filename must be inserted later
} else {
parameters << QStringLiteral("-i") << s_url;
}
bool replaceVfParams = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment