Allow passing pre-parameters using "-i" to specify where the input file name...

Allow passing pre-parameters using "-i" to specify where the input file name should go in ffmpeg parameters
Should work in proxy and transcoding, for example:
-vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i -an -c:v dnxhd
Will insert source file name after "-i".
CCBUG: 378832
parent 3404da90
......@@ -3345,7 +3345,7 @@ void MainWindow::slotTranscode(const QStringList &urls)
m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
return;
}
qCDebug(KDENLIVE_LOG) << "// TRANSODINF FOLDER: " << pCore->bin()->getFolderInfo();
qCDebug(KDENLIVE_LOG) << "// TRANSODING FOLDER: " << pCore->bin()->getFolderInfo();
ClipTranscode *d = new ClipTranscode(urls, params, QStringList(), desc, pCore->bin()->getFolderInfo());
connect(d, &ClipTranscode::addClip, this, &MainWindow::slotAddProjectClip);
d->show();
......
......@@ -46,13 +46,17 @@ ClipTranscode::ClipTranscode(const QStringList &urls, const QString &params, con
auto_add->setChecked(KdenliveSettings::add_new_clip());
if (m_urls.count() == 1) {
QString fileName = m_urls.first(); //.section(QLatin1Char('.'), 0, -1);
QString newFile = params.section(QLatin1Char(' '), -1).replace(QLatin1String("%1"), fileName);
QUrl dest = QUrl::fromLocalFile(newFile);
source_url->setUrl(QUrl::fromLocalFile(m_urls.first()));
QString fileName = m_urls.first();
source_url->setUrl(QUrl::fromLocalFile(fileName));
dest_url->setMode(KFile::File);
dest_url->setUrl(dest);
dest_url->setMode(KFile::File);//OperationMode(KFileDialog::Saving);
#if KXMLGUI_VERSION_MINOR > 32 || KXMLGUI_VERSION_MAJOR > 5
dest_url->setAcceptMode(QFileDialog::AcceptSave);
#endif
if (!params.isEmpty()) {
QString newFile = params.section(QLatin1Char(' '), -1).replace(QLatin1String("%1"), fileName);
QUrl dest = QUrl::fromLocalFile(newFile);
dest_url->setUrl(dest);
}
urls_list->setHidden(true);
connect(source_url, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateParams()));
} else {
......@@ -145,7 +149,11 @@ void ClipTranscode::slotStartTransCode()
}
QString extension = params.section(QStringLiteral("%1"), 1, 1).section(QLatin1Char(' '), 0, 0);
QString s_url = source_url->url().toLocalFile();
parameters << QStringLiteral("-i") << s_url;
if (params.contains(QLatin1String("-i "))) {
// Filename must be inserted later
} else {
parameters << QStringLiteral("-i") << s_url;
}
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
......@@ -170,6 +178,9 @@ void ClipTranscode::slotStartTransCode()
} else if (!m_postParams.isEmpty() && s == QLatin1String("-vf")) {
replaceVfParams = true;
parameters << s;
} else if (s == QLatin1String("-i")) {
parameters << s;
parameters << s_url;
} else {
parameters << s;
}
......
......@@ -85,13 +85,18 @@ void CutClipJob::startJob()
parameters << QStringLiteral("-select_streams") << QStringLiteral("v") << QStringLiteral("-show_frames") << QStringLiteral("-hide_banner") << QStringLiteral("-of") << QStringLiteral("json=c=1") << m_src;
exec = KdenliveSettings::ffprobepath();
} else {
parameters << QStringLiteral("-i") << m_src;
if (!m_cutExtraParams.contains(QLatin1String("-i "))) {
parameters << QStringLiteral("-i") << m_src;
}
if (!m_start.isEmpty()) {
parameters << QStringLiteral("-ss") << m_start << QStringLiteral("-t") << m_end;
}
if (!m_cutExtraParams.isEmpty()) {
foreach (const QString &s, m_cutExtraParams.split(QLatin1Char(' '))) {
parameters << s;
if (s == QLatin1String("-i")) {
parameters << m_src;
}
}
}
......
......@@ -172,11 +172,19 @@ void ProxyJob::startJob()
// The noautorotate flag must be passed before input source
parameters << QStringLiteral("-noautorotate");
}
parameters << QStringLiteral("-i") << m_src;
if (m_proxyParams.contains(QLatin1String("-i "))) {
// we have some pre-filename parameters, filename will be inserted later
} else {
parameters << QStringLiteral("-i") << m_src;
}
QString params = m_proxyParams;
foreach (const QString &s, params.split(QLatin1Char(' '))) {
if (s != QLatin1String("-noautorotate")) {
parameters << s;
QString t = s.simplified();
if (t != QLatin1String("-noautorotate")) {
parameters << t;
if (t == QLatin1String("-i")) {
parameters << m_src;
}
}
}
......
......@@ -308,8 +308,6 @@
<zorder>video_thumbs</zorder>
<zorder>audio_thumbs</zorder>
<zorder>enable_proxy</zorder>
<zorder></zorder>
<zorder>horizontalSpacer</zorder>
<zorder>previewparams</zorder>
</widget>
<widget class="QWidget" name="tab_3">
......
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