Add audio sync option in clip properties to allow correcting audio offset

parent eea832b8
Pipeline #7137 passed with stage
in 13 minutes
......@@ -705,7 +705,6 @@ Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent)
connect(m_itemModel.get(), &ProjectItemModel::refreshPanel, this, &Bin::refreshPanel);
connect(m_itemModel.get(), &ProjectItemModel::refreshAudioThumbs, this, &Bin::doRefreshAudioThumbs);
connect(m_itemModel.get(), &ProjectItemModel::refreshClip, this, &Bin::refreshClip);
connect(m_itemModel.get(), &ProjectItemModel::updateTimelineProducers, this, &Bin::updateTimelineProducers);
connect(m_itemModel.get(), &ProjectItemModel::emitMessage, this, &Bin::emitMessage);
connect(m_itemModel.get(), static_cast<void (ProjectItemModel::*)(const QStringList &, const QModelIndex &)>(&ProjectItemModel::itemDropped), this,
......@@ -2959,15 +2958,6 @@ void Bin::slotUpdateClipProperties(const QString &id, const QMap<QString, QStrin
}
}
void Bin::updateTimelineProducers(const QString &id, const QMap<QString, QString> &passProperties)
{
Q_UNUSED(id)
Q_UNUSED(passProperties)
// TODO REFAC
// pCore->projectManager()->currentTimeline()->updateClipProperties(id, passProperties);
// m_doc->renderer()->updateSlowMotionProducers(id, passProperties);
}
void Bin::showSlideshowWidget(const std::shared_ptr<ProjectClip> &clip)
{
QString folder = QFileInfo(clip->url()).absolutePath();
......
......@@ -341,8 +341,6 @@ public slots:
/** @brief Add extra data to a clip. */
void slotAddClipExtraData(const QString &id, const QString &key, const QString &data = QString(), QUndoCommand *groupCommand = nullptr);
void slotUpdateClipProperties(const QString &id, const QMap<QString, QString> &properties, bool refreshPropertiesPanel);
/** @brief Pass some important properties to timeline track producers. */
void updateTimelineProducers(const QString &id, const QMap<QString, QString> &passProperties);
/** @brief Add effect to active Bin clip (used when double clicking an effect in list). */
void slotAddEffect(QString id, const QStringList &effectData);
/** @brief Request current frame from project monitor.
......
......@@ -949,7 +949,7 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
// Some properties also need to be passed to track producers
QStringList timelineProperties{
QStringLiteral("force_aspect_ratio"), QStringLiteral("set.force_full_luma"), QStringLiteral("full_luma"), QStringLiteral("threads"),
QStringLiteral("force_colorspace"), QStringLiteral("force_tff"), QStringLiteral("force_progressive"),
QStringLiteral("force_colorspace"), QStringLiteral("force_tff"), QStringLiteral("force_progressive"), QStringLiteral("video_delay")
};
QStringList forceReloadProperties{QStringLiteral("autorotate"), QStringLiteral("templatetext"), QStringLiteral("resource"),
QStringLiteral("force_fps"), QStringLiteral("set.test_image"), QStringLiteral("set.test_audio"),
......@@ -1055,7 +1055,27 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
}
}
if (!passProperties.isEmpty() && (!reload || refreshOnly)) {
if (auto ptr = m_model.lock()) emit std::static_pointer_cast<ProjectItemModel>(ptr)->updateTimelineProducers(m_binId, passProperties);
for (auto &p : m_audioProducers) {
QMapIterator<QString, QString> pr(passProperties);
while (pr.hasNext()) {
pr.next();
p.second->set(pr.key().toUtf8().constData(), pr.value().toUtf8().constData());
}
}
for (auto &p : m_videoProducers) {
QMapIterator<QString, QString> pr(passProperties);
while (pr.hasNext()) {
pr.next();
p.second->set(pr.key().toUtf8().constData(), pr.value().toUtf8().constData());
}
}
for (auto &p : m_timewarpProducers) {
QMapIterator<QString, QString> pr(passProperties);
while (pr.hasNext()) {
pr.next();
p.second->set(pr.key().toUtf8().constData(), pr.value().toUtf8().constData());
}
}
}
}
......
......@@ -251,7 +251,6 @@ signals:
void refreshAudioThumbs(const QString &id);
void refreshClip(const QString &id);
void emitMessage(const QString &, int, MessageType);
void updateTimelineProducers(const QString &id, const QMap<QString, QString> &passProperties);
void refreshPanel(const QString &id);
void requestAudioThumbs(const QString &id, long duration);
// TODO
......
......@@ -641,6 +641,28 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
});
hlay->addWidget(audioStream);
vbox->addLayout(hlay);
// Audio sync
hlay = new QHBoxLayout;
hlay->addWidget(new QLabel(i18n("Audio sync")));
auto *spinSync = new QSpinBox(this);
spinSync->setSuffix(i18n("ms"));
spinSync->setRange(-1000, 1000);
spinSync->setValue(qRound(1000 * m_sourceProperties.get_double("video_delay")));
spinSync->setObjectName(QStringLiteral("video_delay"));
if (spinSync->value() != 0) {
m_originalProperties.insert(QStringLiteral("video_delay"), locale.toString(m_sourceProperties.get_double("video_delay")));
}
//QObject::connect(spinSync, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this, spinSync]() {
QObject::connect(spinSync, &QSpinBox::editingFinished, [this, spinSync, locale]() {
QMap<QString, QString> properties;
properties.insert(QStringLiteral("video_delay"), locale.toString(spinSync->value() / 1000.));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
});
hlay->addWidget(spinSync);
vbox->addLayout(hlay);
}
// Colorspace
......
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