Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Allow setting a minimal duration for autodetected scenes to avoid multiple...

Allow setting a minimal duration for autodetected scenes to avoid multiple cuts on fast scene change
parent d72907d9
......@@ -38,10 +38,11 @@
#include <mlt++/Mlt.h>
SceneSplitJob::SceneSplitJob(const QString &binId, bool subClips, int markersType)
SceneSplitJob::SceneSplitJob(const QString &binId, bool subClips, int markersType, int minInterval)
: MeltJob(binId, STABILIZEJOB, true, -1, -1)
, m_subClips(subClips)
, m_markersType(markersType)
, m_minInterval(minInterval)
{
}
......@@ -100,8 +101,9 @@ int SceneSplitJob::prepareJob(std::shared_ptr<JobManager> ptr, const std::vector
}
int markersType = ui.add_markers->isChecked() ? ui.marker_type->currentIndex() : -1;
bool subclips = ui.cut_scenes->isChecked();
int minInterval = ui.minDuration->value();
return ptr->startJob_noprepare<SceneSplitJob>(binIds, parentId, std::move(undoString), subclips, markersType);
return ptr->startJob_noprepare<SceneSplitJob>(binIds, parentId, std::move(undoString), subclips, markersType, minInterval);
}
bool SceneSplitJob::commitResult(Fun &undo, Fun &redo)
......@@ -129,9 +131,15 @@ bool SceneSplitJob::commitResult(Fun &undo, Fun &redo)
QJsonArray list;
QStringList markerData = result.split(QLatin1Char(';'));
int ix = 1;
int lastCut = 0;
for (const QString marker : markerData) {
int pos = marker.section(QLatin1Char('='), 0, 0).toInt();
if (m_minInterval > 0 && ix > 1 && pos - lastCut < m_minInterval) {
continue;
}
lastCut = pos;
QJsonObject currentMarker;
currentMarker.insert(QLatin1String("pos"), QJsonValue(marker.section(QLatin1Char('='), 0, 0).toInt()));
currentMarker.insert(QLatin1String("pos"), QJsonValue(pos));
currentMarker.insert(QLatin1String("comment"), QJsonValue(i18n("Scene %1", ix)));
currentMarker.insert(QLatin1String("type"), QJsonValue(m_markersType));
list.push_back(currentMarker);
......
......@@ -43,7 +43,7 @@ public:
@param subClips if true, we create a subclip per found scene
@param markersType The type of markers that will be created to denote scene. Leave -1 for no markers
*/
SceneSplitJob(const QString &binId, bool subClips, int markersType = -1);
SceneSplitJob(const QString &binId, bool subClips, int markersType = -1, int minInterval = 0);
// This is a special function that prepares the stabilize job for a given list of clips.
// Namely, it displays the required UI to configure the job and call startJob with the right set of parameters
......@@ -65,4 +65,6 @@ protected:
bool m_subClips;
int m_markersType;
// @brief minimum scene duration.
int m_minInterval;
};
......@@ -6,17 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>282</width>
<height>115</height>
<width>336</width>
<height>236</height>
</rect>
</property>
<property name="windowTitle">
<string>Scene Cut</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1" colspan="2">
<widget class="KComboBox" name="marker_type"/>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="add_markers">
<property name="text">
......@@ -27,10 +24,10 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="zone_only">
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="cut_scenes">
<property name="text">
<string>Analyze only selected zone</string>
<string>Cut scenes</string>
</property>
</widget>
</item>
......@@ -47,7 +44,17 @@
</property>
</spacer>
</item>
<item row="5" column="0" colspan="3">
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="zone_only">
<property name="text">
<string>Analyze only selected zone</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="KComboBox" name="marker_type"/>
</item>
<item row="6" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -57,17 +64,27 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="cut_scenes">
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="store_data">
<property name="text">
<string>Cut scenes</string>
<string>Save result in clip metadata</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="store_data">
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Save result in clip metadata</string>
<string>Minimum scene length</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QSpinBox" name="minDuration">
<property name="suffix">
<string> frames</string>
</property>
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
......
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