mirror of
https://invent.kde.org/multimedia/kdenlive
synced 2025-12-05 15:59:59 +01:00
Correctly set audio flag for generator clips (don't pretend we have an audio track when we don't)
Related to !546
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
<paramlistdisplay>Seconds to 0,Seconds to 1,Frames,Timecode,Clock</paramlistdisplay>
|
||||
<name>Counter Style</name>
|
||||
</parameter>
|
||||
<parameter type="list" name="sound" default="silent" paramlist="silent;2pop;frame0">
|
||||
<parameter type="list" name="sound" default="silent" paramlist="silent;2pop;frame0" audio="2pop;frame0">
|
||||
<paramlistdisplay>Silent,1kHz beep before end,1kHz beep each second</paramlistdisplay>
|
||||
<name>Sound</name>
|
||||
</parameter>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE kpartgui>
|
||||
<generator tag="noise" id="noise">
|
||||
<generator tag="noise" id="noise" type="audio;video">
|
||||
<name>White Noise</name>
|
||||
<description>White noise producer</description>
|
||||
<author>Charles Yates</author>
|
||||
|
||||
@@ -79,6 +79,26 @@ Generators::Generators(const QString &path, QWidget *parent)
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
lay->addWidget(buttonBox);
|
||||
m_timePos->setValue(KdenliveSettings::color_duration());
|
||||
if (base.attribute(QStringLiteral("type")).contains(QLatin1String("audio"))) {
|
||||
// Alwasy produces audio
|
||||
m_audioCondition.insert(QStringLiteral("audio"), {});
|
||||
} else {
|
||||
// Check if this generator can provide audio
|
||||
QDomNodeList params = base.elementsByTagName(QStringLiteral("parameter"));
|
||||
for (int i = 0; i < params.count(); ++i) {
|
||||
QDomElement currentParameter = params.item(i).toElement();
|
||||
if (currentParameter.hasAttribute(QLatin1String("audio"))) {
|
||||
const QString audioVals = currentParameter.attribute(QStringLiteral("audio"));
|
||||
QStringList audioValsList;
|
||||
if (audioVals.contains(QLatin1Char(';'))) {
|
||||
audioValsList = audioVals.split(QLatin1Char(';'), Qt::SkipEmptyParts);
|
||||
} else {
|
||||
audioValsList = {audioVals};
|
||||
}
|
||||
m_audioCondition.insert(currentParameter.attribute(QStringLiteral("name")), audioValsList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,9 +193,15 @@ QUrl Generators::getSavedClip(QString clipFolder)
|
||||
|
||||
if (url.isValid()) {
|
||||
Mlt::Tractor trac(pCore->getProjectProfile());
|
||||
Mlt::Playlist playlist(pCore->getProjectProfile());
|
||||
m_producer->set("length", m_timePos->getValue());
|
||||
m_producer->set_in_and_out(0, m_timePos->getValue() - 1);
|
||||
trac.set_track(*m_producer, 0);
|
||||
playlist.append(*m_producer);
|
||||
trac.set_track(playlist, 0);
|
||||
if (!hasAudio()) {
|
||||
Mlt::Producer trackProducer(trac.track(0));
|
||||
trackProducer.set("hide", 2);
|
||||
}
|
||||
QReadLocker lock(&pCore->xmlMutex);
|
||||
Mlt::Consumer c(pCore->getProjectProfile(), "xml", url.toLocalFile().toUtf8().constData());
|
||||
c.connect(trac);
|
||||
@@ -184,3 +210,19 @@ QUrl Generators::getSavedClip(QString clipFolder)
|
||||
}
|
||||
return QUrl();
|
||||
}
|
||||
|
||||
bool Generators::hasAudio() const
|
||||
{
|
||||
if (m_audioCondition.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
const QStringList paramCondition = m_audioCondition.value(m_audioCondition.firstKey());
|
||||
if (paramCondition.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
const QString paramVal = m_producer->get(m_audioCondition.firstKey().toUtf8().constData());
|
||||
if (paramCondition.contains(paramVal)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ private:
|
||||
std::shared_ptr<AssetParameterModel> m_assetModel;
|
||||
QLabel *m_preview;
|
||||
QPixmap m_pixmap;
|
||||
QMap<QString, QStringList> m_audioCondition;
|
||||
bool hasAudio() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateProducer();
|
||||
|
||||
Reference in New Issue
Block a user