Fix some bugs in handling of NVidia HWaccel for proxies and timeline preview

parent 4dcc8eda
Pipeline #6146 passed with stage
in 30 minutes and 35 seconds
......@@ -6,7 +6,7 @@ MPEG=qscale=4 ab=192k vcodec=mpeg2video acodec=mp2 threads=%threads;mpg
[proxy]
x264=-vf scale=720:-2 -vcodec libx264 -g 1 -bf 0 -vb 0 -crf 20 -preset veryfast -acodec aac -ab 128k;mov
x264-vaapi=-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i -vf format=nv12,hwupload,scale_vaapi=720:-2 -vcodec h264_vaapi -g 1 -bf 0 -vb 0 -crf 20 -acodec aac -ab 128k;mov
x264-nvenc=-hwaccel cuvid -c:v %nvcodec -i -filter:v scale_cuda=720:-2 -vcodec h264_nvenc -g 1 -bf 0 -vb 0 -acodec copy;mov
x264-nvenc=-hwaccel cuvid -c:v %nvcodec -i -vf scale_npp=720:-2 -vcodec h264_nvenc -g 1 -bf 0 -vb 0 -preset fast -acodec copy;mov
MPEG2=-vf scale=720:-2 -g 1 -bf 0 -vb 0 -qscale 6 -ab 128k -vcodec mpeg2video -acodec ac3;mpg
MJPEG=-vf yadif,scale=720:-2 -qscale 3 -vcodec mjpeg -acodec pcm_s16le;mkv
MJPEG-vaapi=-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i -vf format=nv12,hwupload,scale_vaapi=720:-2 -vcodec mjpeg_vaapi -acodec copy;mkv
......@@ -31,5 +31,5 @@ DNxHD 1080p 59.94fps=r=59.94 s=1920x1080 vb=90M threads=0 vcodec=dnxhd progressi
DNxHD 1080p 60fps=r=60 s=1920x1080 vb=90M threads=0 vcodec=dnxhd progressive=1;mov
ProRes=vcodec=prores_ks vb=0 g=1 bf=0 vprofile=0 vendor=ap10 qscale=4 s=800x450;mov
MJPEG=f=avi vcodec=mjpeg progressive=1 qscale=1;avi
x264-nvenc=vcodec=h264_nvenc g=1 bf=0 profile=0;mkv
x264-nvenc=vcodec=h264_nvenc g=1 bf=0 profile=0 preset=fast qmin=10 qmax=30;mkv
x264-vaapi=vcodec=h264_vaapi g=1 bf=0 profile=578;mkv
......@@ -955,7 +955,7 @@ void Wizard::testHwEncoders()
tmp.close();
// VAAPI testing
QStringList args{"-y",
QStringList args{"-hide_banner", "-y",
"-vaapi_device",
"/dev/dri/renderD128",
"-f",
......@@ -996,7 +996,7 @@ void Wizard::testHwEncoders()
return;
}
tmp2.close();
QStringList args2{"-y", "-hwaccel", "cuvid", "-f", "lavfi", "-i", "smptebars=duration=5:size=1280x720:rate=25",
QStringList args2{"-hide_banner", "-y", "-hwaccel", "cuvid", "-f", "lavfi", "-i", "smptebars=duration=5:size=1280x720:rate=25",
"-c:v", "h264_nvenc", "-an", "-f", "mp4", tmp2.fileName()};
qDebug() << "// FFMPEG ARGS: " << args2;
hwEncoders.start(KdenliveSettings::ffmpegpath(), args2);
......@@ -1016,6 +1016,23 @@ void Wizard::testHwEncoders()
}
}
KdenliveSettings::setNvencEnabled(nvencSupported);
// Testing NVIDIA SCALER
QStringList args3{"-hide_banner", "-filters"};
qDebug() << "// FFMPEG ARGS: " << args3;
hwEncoders.start(KdenliveSettings::ffmpegpath(), args3);
bool nvScalingSupported = false;
if (hwEncoders.waitForFinished()) {
QByteArray output = hwEncoders.readAll();
hwEncoders.close();
if (output.contains(QByteArray("scale_npp"))) {
qDebug() << "/// ++ SCALE_NPP YES SUPPORTED ::::::";
nvScalingSupported = true;
} else {
qDebug() << "/// ++ SCALE_NPP NOT SUPPORTED";
}
}
KdenliveSettings::setNvScalingEnabled(nvScalingSupported);
}
void Wizard::updateHwStatus()
......
......@@ -209,17 +209,15 @@ bool ProxyJob::startJob()
return true;
} else {
m_isFfmpegJob = true;
QStringList parameters;
if (KdenliveSettings::ffmpegpath().isEmpty()) {
// FFmpeg not detected, cannot process the Job
m_errorMessage.prepend(i18n("Failed to create proxy. FFmpeg not found, please set path in Kdenlive's settings Environment"));
m_done = true;
return false;
}
m_jobDuration = (int)binClip->duration().seconds();
parameters << QStringLiteral("-y") << QStringLiteral("-stats");
// Only output error data
parameters << QStringLiteral("-v") << QStringLiteral("error");
QStringList parameters = {QStringLiteral("-hide_banner"), QStringLiteral("-y"), QStringLiteral("-stats"), QStringLiteral("-v"), QStringLiteral("error")};
m_jobDuration = (int)binClip->duration().seconds();
QString proxyParams = pCore->currentDoc()->getDocumentProperty(QStringLiteral("proxyparams")).simplified();
if (proxyParams.isEmpty()) {
// Automatic setting, decide based on hw support
......@@ -235,7 +233,7 @@ bool ProxyJob::startJob()
QStringList supportedPixFmts{QStringLiteral("yuv420p"), QStringLiteral("yuyv422"), QStringLiteral("rgb24"),
QStringLiteral("bgr24"), QStringLiteral("yuv422p"), QStringLiteral("yuv444p"),
QStringLiteral("rgb32"), QStringLiteral("yuv410p"), QStringLiteral("yuv411p")};
bool supported = supportedCodecs.contains(codec) && supportedPixFmts.contains(pix_fmt);
bool supported = KdenliveSettings::nvScalingEnabled() && supportedCodecs.contains(codec) && supportedPixFmts.contains(pix_fmt);
if (supported) {
// Full hardware decoding supported
codec.append(QStringLiteral("_cuvid"));
......@@ -243,6 +241,7 @@ bool ProxyJob::startJob()
} else {
proxyParams = proxyParams.section(QStringLiteral("-i"), 1);
proxyParams.replace(QStringLiteral("scale_cuda"), QStringLiteral("scale"));
proxyParams.replace(QStringLiteral("scale_npp"), QStringLiteral("scale"));
if (!supportedPixFmts.contains(pix_fmt)) {
proxyParams.prepend(QStringLiteral("-pix_fmt yuv420p"));
}
......@@ -259,7 +258,7 @@ bool ProxyJob::startJob()
parameters << QStringLiteral("-i") << source;
}
QString params = proxyParams;
for (const QString &s : params.split(QLatin1Char(' '))) {
for (const QString &s : params.split(QLatin1Char(' '), QString::SkipEmptyParts)) {
QString t = s.simplified();
if (t != QLatin1String("-noautorotate")) {
parameters << t;
......@@ -271,7 +270,7 @@ bool ProxyJob::startJob()
// Make sure we don't block when proxy file already exists
parameters << dest;
// qDebug()<<"/// FULL PROXY PARAMS:\n"<<parameters<<"\n------";
qDebug()<<"/// FULL PROXY PARAMS:\n"<<parameters<<"\n------";
m_jobProcess = new QProcess;
// m_jobProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(m_jobProcess, &QProcess::readyReadStandardError, this, &ProxyJob::processLogInfo);
......
......@@ -217,7 +217,10 @@
<label>Enables nvenc hw accel in encoders.</label>
<default>false</default>
</entry>
<entry name="nvScalingEnabled" type="Bool">
<label>Enables nvenc hw accel scaling.</label>
<default>false</default>
</entry>
</group>
<group name="timeline">
......
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