Skip to content

Commit

Permalink
Encode subtitles in output files
Browse files Browse the repository at this point in the history
The user must first add subtitles to the timeline using the
subtitle panel
  • Loading branch information
bmatherly committed Jul 27, 2024
1 parent 962002f commit 81220a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/docks/encodedock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,24 @@ void EncodeDock::collectProperties(QDomElement &node, int realtime)
delete p;
}

void EncodeDock::setSubtitleProperties(QDomElement &node, Mlt::Producer *service)
{
if (!service) {
return;
}
int subIndex = 0;
for (int i = 0; i < service->filter_count(); i++) {
QScopedPointer<Mlt::Filter> filter(service->filter(i));
if (filter && filter->is_valid() && filter->get("mlt_service") == QString("subtitle_feed")) {
QString key = QString("subtitle.%1.feed").arg(subIndex);
node.setAttribute(key, filter->get("feed"));
key = QString("subtitle.%1.lang").arg(subIndex);
node.setAttribute(key, filter->get("lang"));
subIndex++;
}
}
}

MeltJob *EncodeDock::createMeltJob(Mlt::Producer *service, const QString &target, int realtime,
int pass, const QThread::Priority priority)
{
Expand Down Expand Up @@ -1124,6 +1142,7 @@ MeltJob *EncodeDock::createMeltJob(Mlt::Producer *service, const QString &target
ui->audioCodecCombo->currentIndex() == 0 &&
(mytarget.endsWith(".mp4") || mytarget.endsWith(".mov")))
consumerNode.setAttribute("strict", "experimental");
setSubtitleProperties(consumerNode, service);

// Add autoclose to playlists.
QDomNodeList playlists = dom.elementsByTagName("playlist");
Expand Down
1 change: 1 addition & 0 deletions src/docks/encodedock.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ private slots:
void loadPresets();
Mlt::Properties *collectProperties(int realtime, bool includeProfile = false);
void collectProperties(QDomElement &node, int realtime);
void setSubtitleProperties(QDomElement &node, Mlt::Producer *service);
MeltJob *createMeltJob(Mlt::Producer *service, const QString &target, int realtime, int pass = 0,
const QThread::Priority priority = Settings.jobPriority());
void runMelt(const QString &target, int realtime = -1);
Expand Down

0 comments on commit 81220a2

Please sign in to comment.