Commit c10a0984 authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

[Render Widget] Backend option to set speed default index

Also set the default speed for x254 and x256 to "veryfast"
(See https://superuser.com/questions/1556953/why-does-preset-veryfast-
in-ffmpeg-generate-the-most-compressed-file-compared)

Related to #1455
parent 7a54eea5
......@@ -8,7 +8,7 @@
qualities="15,45" defaultquality="25"
audiobitrates="256,64" defaultaudiobitrate="160"
args="f=mp4 movflags=+faststart vcodec=libx264 crf=%quality g=15 acodec=aac ab=%audiobitrate+'k'"
speeds="preset=veryslow;preset=slower;preset=slow;preset=medium;preset=faster;preset=fast;preset=faster;preset=veryfast;preset=superfast;preset=ultrafast"/>
defaultspeedindex="6" speeds="preset=veryslow;preset=slower;preset=slow;preset=medium;preset=fast;preset=faster;preset=veryfast;preset=superfast;preset=ultrafast"/>
<profile name="MPEG-2" extension="mpg"
qualities="3,15" defaultquality="5"
audioqualities="3,7" defaultaudioquality="3"
......@@ -29,7 +29,7 @@
qualities="15,45" defaultquality="25"
audiobitrates="256,64" defaultaudiobitrate="160"
args="properties=x265-medium f=mp4 vcodec=libx265 crf=%quality acodec=aac ab=%audiobitrate+'k'"
speeds="preset=veryslow;preset=slower;preset=slow;preset=medium;preset=faster;preset=fast;preset=faster;preset=veryfast;preset=superfast;preset=ultrafast"/>
defaultspeedindex="6" speeds="preset=veryslow;preset=slower;preset=slow;preset=medium;preset=fast;preset=faster;preset=veryfast;preset=superfast;preset=ultrafast"/>
</group>
<group name="Video with Alpha" renderer="avformat" type="av">
<profile name="Alpha VP8" extension="webm"
......
......@@ -1196,10 +1196,9 @@ void RenderWidget::loadProfile()
m_view.buttonEdit->setEnabled(profile->editable());
if (!profile->speeds().isEmpty()) {
int speed = profile->speeds().count() - 1;
m_view.speed->setEnabled(true);
m_view.speed->setMaximum(speed);
m_view.speed->setValue(speed * 3 / 4); // default to intermediate speed
m_view.speed->setMaximum(profile->speeds().count() - 1);
m_view.speed->setValue(profile->defaultSpeedIndex());
} else {
m_view.speed->setEnabled(false);
}
......
......@@ -31,6 +31,7 @@ RenderPresetModel::RenderPresetModel(QDomElement preset, const QString &presetFi
, m_renderer(renderer)
, m_url(preset.attribute(QStringLiteral("url")))
, m_speeds(preset.attribute(QStringLiteral("speeds")))
, m_defaultSpeedIndex(preset.attribute(QStringLiteral("defaultspeedindex"), QStringLiteral("-1")).toInt())
, m_topFieldFirst(preset.attribute(QStringLiteral("top_field_first")))
{
if (m_groupName.isEmpty()) {
......@@ -47,6 +48,10 @@ RenderPresetModel::RenderPresetModel(QDomElement preset, const QString &presetFi
m_params.append(QStringLiteral(" f=%1").arg(m_extension));
}
if (m_defaultSpeedIndex < 0) {
m_defaultSpeedIndex = (speeds().count() - 1) * 0.75;
}
m_vQualities = preset.attribute(QStringLiteral("qualities"));
m_defaultVQuality = preset.attribute(QStringLiteral("defaultquality"));
m_vBitrates = preset.attribute(QStringLiteral("bitrates"));
......@@ -65,6 +70,7 @@ RenderPresetModel::RenderPresetModel(const QString &groupName, const QString &pa
, m_params(params)
, m_groupName(groupName)
, m_renderer(QStringLiteral("avformat"))
, m_defaultSpeedIndex(-1)
{
KConfig config(path, KConfig::SimpleConfig);
KConfigGroup group = config.group(QByteArray());
......@@ -92,8 +98,9 @@ RenderPresetModel::RenderPresetModel(const QString &groupName, const QString &pa
checkPreset();
}
RenderPresetModel::RenderPresetModel(const QString &name, const QString &groupName, const QString &params, const QString &defaultVBitrate, const QString &defaultVQuality,
const QString &defaultABitrate, const QString &defaultAQuality, const QString &speeds)
RenderPresetModel::RenderPresetModel(const QString &name, const QString &groupName, const QString &params, const QString &defaultVBitrate,
const QString &defaultVQuality, const QString &defaultABitrate, const QString &defaultAQuality,
const QString &speedsString)
: m_presetFile()
, m_editable()
, m_name(name)
......@@ -104,7 +111,7 @@ RenderPresetModel::RenderPresetModel(const QString &name, const QString &groupNa
, m_groupName(groupName)
, m_renderer(QStringLiteral("avformat"))
, m_url()
, m_speeds(speeds)
, m_speeds(speedsString)
, m_topFieldFirst()
, m_vBitrates()
, m_defaultVBitrate(defaultVBitrate)
......@@ -119,6 +126,8 @@ RenderPresetModel::RenderPresetModel(const QString &name, const QString &groupNa
m_groupName = i18nc("Category Name", "Custom");
}
m_defaultSpeedIndex = (speeds().count() - 1) * 0.75;
checkPreset();
}
......@@ -231,6 +240,9 @@ QDomElement RenderPresetModel::toXml()
if (!m_speeds.isEmpty()) {
// profile has a variable speed
profileElement.setAttribute(QStringLiteral("speeds"), m_speeds);
if (m_defaultSpeedIndex > 0) {
profileElement.setAttribute(QStringLiteral("defaultspeedindex"), m_defaultSpeedIndex);
}
}
return doc.documentElement();
}
......
......@@ -25,8 +25,8 @@ public:
RenderPresetModel(QDomElement preset, const QString &presetFile, bool editable, const QString &groupName = QString(),
const QString &renderer = QStringLiteral("avformat"));
RenderPresetModel(const QString &groupName, const QString &path, QString presetName, const QString &params, bool codecInName);
RenderPresetModel(const QString &name, const QString &groupName, const QString &params, const QString &defaultVBitrate,
const QString &defaultVQuality, const QString &defaultABitrate, const QString &defaultAQuality, const QString &speeds);
RenderPresetModel(const QString &name, const QString &groupName, const QString &params, const QString &defaultVBitrate, const QString &defaultVQuality,
const QString &defaultABitrate, const QString &defaultAQuality, const QString &speedsString);
enum InstallType {
BuildIn,
......@@ -53,6 +53,7 @@ public:
QString renderer() const { return m_renderer; };
QString url() const;
QStringList speeds() const;
int defaultSpeedIndex() const { return m_defaultSpeedIndex; };
QString topFieldFirst() const { return m_topFieldFirst; };
QString presetFile() const { return m_presetFile; };
QStringList audioBitrates() const;
......@@ -91,6 +92,7 @@ private:
QString m_renderer;
QString m_url;
QString m_speeds;
int m_defaultSpeedIndex;
QString m_topFieldFirst;
QString m_vBitrates;
QString m_defaultVBitrate;
......
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