Browse Source

SubtitleWriter: always start a new text entry where the previous ended

QGC4.4
Willian Galvani 5 years ago committed by Don Gagne
parent
commit
e06da9e270
  1. 6
      src/VideoManager/SubtitleWriter.cc
  2. 2
      src/VideoManager/SubtitleWriter.h

6
src/VideoManager/SubtitleWriter.cc

@ -39,7 +39,8 @@ void SubtitleWriter::startCapturingTelemetry(const QString& videoFile) @@ -39,7 +39,8 @@ void SubtitleWriter::startCapturingTelemetry(const QString& videoFile)
_values = settings.value("large").toStringList().replaceInStrings(QStringLiteral("Vehicle."), QString());
_values += settings.value("small").toStringList().replaceInStrings(QStringLiteral("Vehicle."), QString());
_startTime = QDateTime::currentDateTime();
// One subtitle always starts where the previous ended
_lastEndTime = QTime(0, 0);
QFileInfo videoFileInfo(videoFile);
QString subtitleFilePath = QStringLiteral("%1/%2.ass").arg(videoFileInfo.path(), videoFileInfo.completeBaseName());
@ -108,10 +109,11 @@ void SubtitleWriter::_captureTelemetry() @@ -108,10 +109,11 @@ void SubtitleWriter::_captureTelemetry()
}
// The time to start displaying this subtitle text
QTime start = QTime(0, 0).addMSecs(_startTime.time().msecsTo(QDateTime::currentDateTime().time()));
QTime start = _lastEndTime;
// The time to stop displaying this subtitle text
QTime end = start.addMSecs(1000/_sampleRate);
_lastEndTime = end;
// This splits the screen in N parts and uses the N-1 internal parts to align the subtitles to.
// Should we try to get the resolution from the pipeline? This seems to work fine with other resolutions too.

2
src/VideoManager/SubtitleWriter.h

@ -43,7 +43,7 @@ private slots: @@ -43,7 +43,7 @@ private slots:
private:
QTimer _timer;
QStringList _values;
QDateTime _startTime;
QTime _lastEndTime;
QFile _file;
static const int _sampleRate;

Loading…
Cancel
Save