Commit 19d7d4cc authored by Dmitry Kazakov's avatar Dmitry Kazakov

Implement attaching audio into the rendered video file

parent a44f547b
......@@ -227,6 +227,9 @@ KisPropertiesConfigurationSP DlgAnimationRenderer::getVideoConfiguration() const
}
cfg->setProperty("filename", filename);
cfg->setProperty("delete_sequence", m_page->chkDeleteSequence->isChecked());
cfg->setProperty("first_frame", m_page->intStart->value());
cfg->setProperty("last_frame", m_page->intEnd->value());
cfg->setProperty("sequence_start", m_page->sequenceStart->value());
return cfg;
}
......
......@@ -43,6 +43,7 @@
#include <QEventLoop>
#include <QTemporaryFile>
#include <QTemporaryDir>
#include <QTime>
#include "KisPart.h"
......@@ -221,7 +222,7 @@ KisImageBuilder_Result VideoSaver::encode(const QString &filename, KisProperties
KisImageAnimationInterface *animation = m_image->animationInterface();
const KisTimeRange fullRange = animation->fullClipRange();
const KisTimeRange clipRange(configuration->getInt("firstframe", fullRange.start()), configuration->getInt("lastFrame"), fullRange.end());
const KisTimeRange clipRange(configuration->getInt("first_frame", fullRange.start()), configuration->getInt("last_frame", fullRange.end()));
const int frameRate = animation->framerate();
const QDir framesDir(configuration->getString("directory"));
......@@ -283,8 +284,24 @@ KisImageBuilder_Result VideoSaver::encode(const QString &filename, KisProperties
} else {
QStringList args;
args << "-r" << QString::number(frameRate)
<< "-i" << savedFilesMask
<< additionalOptionsList
<< "-i" << savedFilesMask;
QFileInfo audioFileInfo = animation->audioChannelFileName();
if (!animation->isAudioMuted() && audioFileInfo.exists()) {
const int msecStart = clipRange.start() * 1000 / animation->framerate();
const int msecDuration = clipRange.duration() * 1000 / animation->framerate();
const QTime startTime = QTime::fromMSecsSinceStartOfDay(msecStart);
const QTime durationTime = QTime::fromMSecsSinceStartOfDay(msecDuration);
const QString ffmpegTimeFormat("H:m:s.zzz");
args << "-ss" << startTime.toString(ffmpegTimeFormat);
args << "-t" << durationTime.toString(ffmpegTimeFormat);
args << "-i" << audioFileInfo.absoluteFilePath();
}
args << additionalOptionsList
<< "-y" << resultFile;
result = m_runner->runFFMpeg(args, i18n("Encoding frames..."),
......
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