sync: masked waveform correlation, stretch sync, manual start time
- Waveform sync no longer treats uncached waveform regions as silence: the envelope extraction now reports a per-window validity mask and the correlation skips invalid windows on either side, improving accuracy for partially cached clips - Add stretch/speed sync: AudioWaveformSync::EstimateStretchAndOffset searches a playback-rate range plus offset, and a new timeline context action 'Synchronize by Waveform (Adjust Speed)' applies the estimated rate as a clip speed change (with undo) when plain offset alignment is inconclusive - Footage properties dialog gains a Source Start Time field so the value used by source-time sync can be viewed and edited manually instead of relying solely on auto-detected metadata; applied via an undo command, with Footage::ClearSourceStartTime() for removal - Regression tests for masked correlation, stretch estimation, the envelope validity mask, and source-start-time set/clear
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "footageproperties.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
@@ -58,6 +59,48 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent,
|
||||
layout->addWidget(footage_name_field_, row, 1);
|
||||
row++;
|
||||
|
||||
// Manual source start time: audio/timecode sync relies on this value,
|
||||
// which is otherwise only auto-detected from file metadata
|
||||
layout->addWidget(new QLabel(tr("Source Start Time:")), row, 0);
|
||||
|
||||
{
|
||||
QHBoxLayout *start_time_layout = new QHBoxLayout();
|
||||
|
||||
source_start_time_enable_ = new QCheckBox(tr("Set"));
|
||||
source_start_time_enable_->setChecked(footage_->HasSourceStartTime());
|
||||
start_time_layout->addWidget(source_start_time_enable_);
|
||||
|
||||
source_start_time_spin_ = new QDoubleSpinBox();
|
||||
source_start_time_spin_->setRange(-86400.0, 86400.0);
|
||||
source_start_time_spin_->setDecimals(3);
|
||||
source_start_time_spin_->setSuffix(QStringLiteral(" s"));
|
||||
source_start_time_spin_->setValue(
|
||||
footage_->HasSourceStartTime() ?
|
||||
footage_->source_start_time().toDouble() :
|
||||
0.0);
|
||||
source_start_time_spin_->setEnabled(
|
||||
source_start_time_enable_->isChecked());
|
||||
start_time_layout->addWidget(source_start_time_spin_, 1);
|
||||
|
||||
QString detection_note;
|
||||
if (footage_->HasSourceStartTime()) {
|
||||
const QString &source = footage_->source_start_time_source();
|
||||
detection_note =
|
||||
(source == QStringLiteral("manual")) ?
|
||||
tr("(set manually)") :
|
||||
tr("(auto-detected: %1)").arg(source);
|
||||
} else {
|
||||
detection_note = tr("(not detected)");
|
||||
}
|
||||
start_time_layout->addWidget(new QLabel(detection_note));
|
||||
|
||||
connect(source_start_time_enable_, &QCheckBox::toggled,
|
||||
source_start_time_spin_, &QDoubleSpinBox::setEnabled);
|
||||
|
||||
layout->addLayout(start_time_layout, row, 1);
|
||||
}
|
||||
row++;
|
||||
|
||||
layout->addWidget(new QLabel(tr("Tracks:")), row, 0, 1, 2);
|
||||
row++;
|
||||
|
||||
@@ -165,6 +208,18 @@ void FootagePropertiesDialog::accept()
|
||||
command->add_child(nrc);
|
||||
}
|
||||
|
||||
// Apply source start time changes
|
||||
{
|
||||
const bool new_enabled = source_start_time_enable_->isChecked();
|
||||
const rational new_time =
|
||||
rational::fromDouble(source_start_time_spin_->value());
|
||||
if (new_enabled != footage_->HasSourceStartTime() ||
|
||||
(new_enabled && new_time != footage_->source_start_time())) {
|
||||
command->add_child(new FootageSetSourceStartTimeCommand(
|
||||
footage_, new_enabled, new_time, QStringLiteral("manual")));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < footage_->GetTotalStreamCount(); i++) {
|
||||
Track::Reference reference = footage_->GetReferenceFromRealIndex(i);
|
||||
bool new_stream_enabled =
|
||||
@@ -279,4 +334,44 @@ void FootagePropertiesDialog::StreamEnableChangeCommand::undo()
|
||||
}
|
||||
}
|
||||
|
||||
FootagePropertiesDialog::FootageSetSourceStartTimeCommand::
|
||||
FootageSetSourceStartTimeCommand(Footage *footage, bool enabled,
|
||||
const rational &time,
|
||||
const QString &source)
|
||||
: footage_(footage)
|
||||
, new_enabled_(enabled)
|
||||
, new_time_(time)
|
||||
, new_source_(source)
|
||||
{
|
||||
}
|
||||
|
||||
Project *
|
||||
FootagePropertiesDialog::FootageSetSourceStartTimeCommand::GetRelevantProject()
|
||||
const
|
||||
{
|
||||
return footage_->project();
|
||||
}
|
||||
|
||||
void FootagePropertiesDialog::FootageSetSourceStartTimeCommand::redo()
|
||||
{
|
||||
old_enabled_ = footage_->HasSourceStartTime();
|
||||
old_time_ = footage_->source_start_time();
|
||||
old_source_ = footage_->source_start_time_source();
|
||||
|
||||
if (new_enabled_) {
|
||||
footage_->SetSourceStartTime(new_time_, new_source_);
|
||||
} else {
|
||||
footage_->ClearSourceStartTime();
|
||||
}
|
||||
}
|
||||
|
||||
void FootagePropertiesDialog::FootageSetSourceStartTimeCommand::undo()
|
||||
{
|
||||
if (old_enabled_) {
|
||||
footage_->SetSourceStartTime(old_time_, old_source_);
|
||||
} else {
|
||||
footage_->ClearSourceStartTime();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,6 +79,30 @@ private:
|
||||
bool new_enabled_;
|
||||
};
|
||||
|
||||
class FootageSetSourceStartTimeCommand : public UndoCommand {
|
||||
public:
|
||||
FootageSetSourceStartTimeCommand(Footage *footage, bool enabled,
|
||||
const rational &time,
|
||||
const QString &source);
|
||||
|
||||
virtual Project *GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Footage *footage_;
|
||||
|
||||
bool new_enabled_;
|
||||
rational new_time_;
|
||||
QString new_source_;
|
||||
|
||||
bool old_enabled_;
|
||||
rational old_time_;
|
||||
QString old_source_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Stack of widgets that changes based on whether the stream is a video or audio stream
|
||||
*/
|
||||
@@ -89,6 +113,16 @@ private:
|
||||
*/
|
||||
QLineEdit *footage_name_field_;
|
||||
|
||||
/**
|
||||
* @brief Whether a manual source start time should be used
|
||||
*/
|
||||
QCheckBox *source_start_time_enable_;
|
||||
|
||||
/**
|
||||
* @brief Source start time in seconds
|
||||
*/
|
||||
QDoubleSpinBox *source_start_time_spin_;
|
||||
|
||||
/**
|
||||
* @brief Internal pointer to Media object (set in constructor)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user