Implement audio sync foundations

This commit is contained in:
2026-07-13 10:19:29 +08:00
parent 4d52267c4a
commit 08b1c6d562
21 changed files with 1094 additions and 18 deletions
@@ -63,6 +63,26 @@ bool FootageDescription::Load(const QString &filename)
while (XMLReadNextStartElement(&reader)) {
if (reader.name() == QStringLiteral("decoder")) {
decoder_ = reader.readElementText();
} else if (reader.name() ==
QStringLiteral("sourcestarttime")) {
QString source;
{
XMLAttributeLoop((&reader), attr)
{
if (attr.name() == QStringLiteral("source")) {
source = attr.value().toString();
}
}
}
const QStringList split =
reader.readElementText().split('/');
if (split.size() == 2) {
SetSourceStartTime(
rational(split.at(0).toInt(),
split.at(1).toInt()),
source);
}
} else if (reader.name() == QStringLiteral("streams")) {
{
XMLAttributeLoop((&reader), attr)
@@ -133,6 +153,16 @@ bool FootageDescription::Save(const QString &filename) const
writer.writeTextElement(QStringLiteral("decoder"), decoder_);
if (has_source_start_time_) {
writer.writeStartElement(QStringLiteral("sourcestarttime"));
writer.writeAttribute(QStringLiteral("source"),
source_start_time_source_);
writer.writeCharacters(QStringLiteral("%1/%2").arg(
QString::number(source_start_time_.numerator()),
QString::number(source_start_time_.denominator())));
writer.writeEndElement();
}
writer.writeStartElement(QStringLiteral("streams"));
writer.writeAttribute(QStringLiteral("count"),
+32 -1
View File
@@ -22,6 +22,8 @@
#ifndef FOOTAGEDESCRIPTION_H
#define FOOTAGEDESCRIPTION_H
#include <QString>
#include "node/output/track/track.h"
#include "render/subtitleparams.h"
#include "render/videoparams.h"
@@ -34,6 +36,7 @@ public:
FootageDescription(const QString &decoder = QString())
: decoder_(decoder)
, total_stream_count_(0)
, has_source_start_time_(false)
{
}
@@ -131,6 +134,28 @@ public:
total_stream_count_ = s;
}
void SetSourceStartTime(const rational &time, const QString &source)
{
source_start_time_ = time;
source_start_time_source_ = source;
has_source_start_time_ = true;
}
bool HasSourceStartTime() const
{
return has_source_start_time_;
}
const rational &source_start_time() const
{
return source_start_time_;
}
const QString &source_start_time_source() const
{
return source_start_time_source_;
}
bool Load(const QString &filename);
bool Save(const QString &filename) const;
@@ -163,7 +188,7 @@ public:
}
private:
static constexpr unsigned kFootageMetaVersion = 6;
static constexpr unsigned kFootageMetaVersion = 7;
QString decoder_;
@@ -174,6 +199,12 @@ private:
QVector<SubtitleParams> subtitle_streams_;
int total_stream_count_;
rational source_start_time_;
QString source_start_time_source_;
bool has_source_start_time_;
};
}