Commit f7c91d9c authored by Dmitry Kazakov's avatar Dmitry Kazakov

Add an option to make embedding audio stream optional

parent 19d7d4cc
......@@ -72,6 +72,11 @@ DlgAnimationRenderer::DlgAnimationRenderer(KisDocument *doc, QWidget *parent)
m_page->intEnd->setMaximum(doc->image()->animationInterface()->fullClipRange().end());
m_page->intEnd->setValue(doc->image()->animationInterface()->playbackRange().end());
QFileInfo audioFileInfo(doc->image()->animationInterface()->audioChannelFileName());
const bool hasAudio = audioFileInfo.exists();
m_page->chkIncludeAudio->setEnabled(hasAudio);
m_page->chkIncludeAudio->setChecked(hasAudio && !doc->image()->animationInterface()->isAudioMuted());
QStringList mimes = KisImportExportManager::mimeFilter(KisImportExportManager::Export);
mimes.sort();
Q_FOREACH(const QString &mime, mimes) {
......@@ -251,6 +256,7 @@ KisPropertiesConfigurationSP DlgAnimationRenderer::getEncoderConfiguration() con
cfg->setProperty("first_frame", m_page->intStart->value());
cfg->setProperty("last_frame", m_page->intEnd->value());
cfg->setProperty("sequence_start", m_page->sequenceStart->value());
cfg->setProperty("include_audio", m_page->chkIncludeAudio->isChecked());
return cfg;
}
......
......@@ -231,7 +231,7 @@
<item row="2" column="1">
<widget class="KisFileNameRequester" name="ffmpegLocation" native="true"/>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="chkDeleteSequence">
<property name="text">
<string>Delete Sequence After Rendering</string>
......@@ -241,7 +241,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -254,6 +254,13 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkIncludeAudio">
<property name="text">
<string>Include Audio</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -222,9 +222,15 @@ KisImageBuilder_Result VideoSaver::encode(const QString &filename, KisProperties
KisImageAnimationInterface *animation = m_image->animationInterface();
const KisTimeRange fullRange = animation->fullClipRange();
const KisTimeRange clipRange(configuration->getInt("first_frame", fullRange.start()), configuration->getInt("last_frame", fullRange.end()));
const int frameRate = animation->framerate();
KIS_SAFE_ASSERT_RECOVER_NOOP(configuration->hasProperty("first_frame"));
KIS_SAFE_ASSERT_RECOVER_NOOP(configuration->hasProperty("last_frame"));
KIS_SAFE_ASSERT_RECOVER_NOOP(configuration->hasProperty("include_audio"));
const KisTimeRange clipRange(configuration->getInt("first_frame", fullRange.start()), configuration->getInt("last_frame", fullRange.end()));
const bool includeAudio = configuration->getBool("include_audio", true);
const QDir framesDir(configuration->getString("directory"));
QString resultFile;
......@@ -286,8 +292,11 @@ KisImageBuilder_Result VideoSaver::encode(const QString &filename, KisProperties
args << "-r" << QString::number(frameRate)
<< "-i" << savedFilesMask;
QFileInfo audioFileInfo = animation->audioChannelFileName();
if (!animation->isAudioMuted() && audioFileInfo.exists()) {
if (includeAudio && audioFileInfo.exists()) {
const int msecStart = clipRange.start() * 1000 / animation->framerate();
const int msecDuration = clipRange.duration() * 1000 / animation->framerate();
......
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