Add config option to enable all (default), first or first 2 audio streams in multi stream clip.

Related to #382
parent 274bbb25
Pipeline #20128 passed with stage
in 9 minutes and 12 seconds
......@@ -254,6 +254,11 @@
<default>false</default>
</entry>
<entry name="multistream" type="Int">
<label>Should we enable all audio streams by default.</label>
<default>0</default>
</entry>
<entry name="videothumbnails" type="Bool">
<label>Display video thumbnails in timeline.</label>
<default>true</default>
......
......@@ -9,6 +9,7 @@ the Free Software Foundation, either version 3 of the License, or
*/
#include "audioStreamInfo.h"
#include "kdenlivesettings.h"
#include "kdenlive_debug.h"
#include <KLocalizedString>
......@@ -71,7 +72,15 @@ AudioStreamInfo::AudioStreamInfo(const std::shared_ptr<Mlt::Producer> &producer,
}
QString active = producer->get("kdenlive:active_streams");
updateActiveStreams(active);
if (m_audioStreams.count() > 1 && active.isEmpty()) {
// initialize enabled streams
QStringList streamString;
for (int streamIx : m_activeStreams) {
streamString << QString::number(streamIx);
}
producer->set("kdenlive:active_streams", streamString.join(QLatin1Char(';')).toUtf8().constData());
}
if (audioStreamIndex > -1) {
QByteArray key;
key = QStringLiteral("meta.media.%1.codec.sample_fmt").arg(audioStreamIndex).toLocal8Bit();
......@@ -166,10 +175,31 @@ void AudioStreamInfo::setAudioIndex(const std::shared_ptr<Mlt::Producer> &produc
void AudioStreamInfo::updateActiveStreams(const QString &activeStreams)
{
// -1 = disable all audio
// empty = enable all audio
// empty = enable all audio or first depending on config
m_activeStreams.clear();
if (activeStreams.isEmpty()) {
m_activeStreams = m_audioStreams.keys();
switch (KdenliveSettings::multistream()) {
case 1:
// Enable first stream only
m_activeStreams << m_audioStreams.firstKey();
break;
case 2:
// Enable the first two streams only
{
QList <int> str = m_audioStreams.keys();
while (!str.isEmpty()) {
m_activeStreams << str.takeFirst();
if (m_activeStreams.size() == 2) {
break;
}
}
break;
}
default:
// Enable all streams
m_activeStreams = m_audioStreams.keys();
break;
}
return;
}
QStringList st = activeStreams.split(QLatin1Char(';'));
......@@ -184,4 +214,3 @@ void AudioStreamInfo::renameStream(int ix, const QString streamName)
m_audioStreams.insert(ix, streamName);
}
}
......@@ -861,8 +861,6 @@ void ClipPropertiesController::slotReloadProperties()
if (audio_ix != m_originalProperties.value(QStringLiteral("audio_index")).toInt()) {
QSignalBlocker bk(m_audioStream);
m_originalProperties.insert(QStringLiteral("audio_index"), QString::number(audio_ix));
// update combo
//m_audioStream->setCurrentIndex(m_audioStream->findData(audio_ix));
}
QList <int> enabledStreams = m_controller->activeStreams().keys();
qDebug()<<"=== GOT ACTIVE STREAMS: "<<enabledStreams;
......
......@@ -6,45 +6,11 @@
<rect>
<x>0</x>
<y>0</y>
<width>391</width>
<height>450</height>
<width>488</width>
<height>460</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_autoscroll">
<property name="text">
<string>Autoscroll while playing</string>
</property>
</widget>
</item>
<item row="9" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_verticalzoom">
<property name="text">
<string>Zoom using vertical drag in ruler</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_showmarkers">
<property name="text">
<string>Display clip markers comments</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_ffmpegaudiothumbnails">
<property name="text">
......@@ -89,7 +55,14 @@
</item>
</layout>
</item>
<item row="7" column="0">
<item row="5" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_automatictransitions">
<property name="text">
<string>Create new transitions as automatic transitions</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Raise properties pane when selecting in timeline</string>
......@@ -119,13 +92,6 @@
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="kcfg_automatictransitions">
<property name="text">
<string>Create new transitions as automatic transitions</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox">
<property name="title">
......@@ -176,6 +142,66 @@
</layout>
</widget>
</item>
<item row="10" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_verticalzoom">
<property name="text">
<string>Zoom using vertical drag in ruler</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_autoscroll">
<property name="text">
<string>Autoscroll while playing</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_showmarkers">
<property name="text">
<string>Display clip markers comments</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>For clips with multiple audio streams, enable </string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="QComboBox" name="kcfg_multistream">
<item>
<property name="text">
<string>All streams</string>
</property>
</item>
<item>
<property name="text">
<string>First stream</string>
</property>
</item>
<item>
<property name="text">
<string>First 2 streams</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<tabstops>
......
......@@ -290,7 +290,7 @@ QStringList ThumbnailCache::getAudioKey(const QString &binId, bool *ok)
*ok = binClip != nullptr;
if (ok) {
QString streams = binClip->getProducerProperty(QStringLiteral("kdenlive:active_streams"));
if (streams.isEmpty() || streams == QString::number(INT_MAX)) {
if (streams == QString::number(INT_MAX)) {
// activate all audio streams
QList <int> streamIxes = binClip->audioStreams().keys();
if (streamIxes.size() > 1) {
......
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