diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index 1e1e05cf4..889037601 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -1,1041 +1,1046 @@ 0 0 4 false true 1 true true false 00:00:05:00 00:00:05:00 00:00:00:01 00:00:03:00 false false false false false false 00:00:05:00 00:00:03:00 true 16 2 2 false false false false 1000 2000 800 0 0 true false false false 0 1 25 false + + + 0 + + true true true true false true false 0 1 true true true false sdl2_audio 0 sdl2_audio 0 #535353 100 true 1 false 0 1 2 0 /tmp/ false true $HOME true default: 100 2 48000 0 0 /dev/video0 2 default 0 true false 0 0 0 false 0 0 1280 720 15.0 true false false 0 0 capture false 3 false true 0 true 0 25 true false false false true true true false false false false 0x15 0x05 1 0 0 false 0x07 true true false false true #000000 true 320 240 true false false true true 5 3 false false false 10 0 false false true false false true true true 0 onefield nearest volume,lift_gamma_gain,qtblend wipe,qtblend 0 false false true false 2 3 #ff0000 0 false diff --git a/src/lib/audio/audioStreamInfo.cpp b/src/lib/audio/audioStreamInfo.cpp index 41b67e099..280374d30 100644 --- a/src/lib/audio/audioStreamInfo.cpp +++ b/src/lib/audio/audioStreamInfo.cpp @@ -1,187 +1,216 @@ /* Copyright (C) 2012 Simon A. Eugster (Granjow) This file is part of kdenlive. See www.kdenlive.org. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. */ #include "audioStreamInfo.h" +#include "kdenlivesettings.h" #include "kdenlive_debug.h" #include #include #include AudioStreamInfo::AudioStreamInfo(const std::shared_ptr &producer, int audioStreamIndex) : m_audioStreamIndex(audioStreamIndex) , m_ffmpegAudioIndex(0) , m_samplingRate(48000) , m_channels(2) , m_bitRate(0) { // Fetch audio streams int streams = producer->get_int("meta.media.nb_streams"); int streamIndex = 1; for (int ix = 0; ix < streams; ix++) { char property[200]; snprintf(property, sizeof(property), "meta.media.%d.stream.type", ix); QString type = producer->get(property); if (type == QLatin1String("audio")) { memset(property, 0, 200); snprintf(property, sizeof(property), "meta.media.%d.codec.channels", ix); int chan = producer->get_int(property); memset(property, 0, 200); snprintf(property, sizeof(property), "kdenlive:streamname.%d", ix); QString channelDescription = producer->get(property); if (channelDescription.isEmpty()) { channelDescription = QString("%1|").arg(streamIndex++); switch (chan) { case 1: channelDescription.append(i18n("Mono ")); break; case 2: channelDescription.append(i18n("Stereo ")); break; default: channelDescription.append(i18n("%1 channels ", chan)); break; } // Frequency memset(property, 0, 200); snprintf(property, sizeof(property), "meta.media.%d.codec.sample_rate", ix); QString frequency(producer->get(property)); if (frequency.endsWith(QLatin1String("000"))) { frequency.chop(3); frequency.append(i18n("kHz ")); } else { frequency.append(i18n("Hz ")); } channelDescription.append(frequency); memset(property, 0, 200); snprintf(property, sizeof(property), "meta.media.%d.codec.name", ix); channelDescription.append(producer->get(property)); } else { streamIndex++; } m_audioStreams.insert(ix, channelDescription); } } 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(); m_samplingFormat = QString::fromLatin1(producer->get(key.data())); key = QStringLiteral("meta.media.%1.codec.sample_rate").arg(audioStreamIndex).toLocal8Bit(); m_samplingRate = producer->get_int(key.data()); key = QStringLiteral("meta.media.%1.codec.bit_rate").arg(audioStreamIndex).toLocal8Bit(); m_bitRate = producer->get_int(key.data()); key = QStringLiteral("meta.media.%1.codec.channels").arg(audioStreamIndex).toLocal8Bit(); m_channels = producer->get_int(key.data()); setAudioIndex(producer, m_audioStreamIndex); } } AudioStreamInfo::~AudioStreamInfo() = default; int AudioStreamInfo::samplingRate() const { return m_samplingRate; } int AudioStreamInfo::channels() const { return m_channels; } QMap AudioStreamInfo::streams() const { return m_audioStreams; } QMap AudioStreamInfo::activeStreams() const { QMap active; QMapIterator i(m_audioStreams); if (m_activeStreams.size() == 1 && m_activeStreams.contains(INT_MAX)) { active.insert(INT_MAX, i18n("Merged streams")); } else { while (i.hasNext()) { i.next(); if (m_activeStreams.contains(i.key())) { active.insert(i.key(), i.value()); } } } return active; } int AudioStreamInfo::bitrate() const { return m_bitRate; } int AudioStreamInfo::audio_index() const { return m_audioStreamIndex; } int AudioStreamInfo::ffmpeg_audio_index() const { return m_ffmpegAudioIndex; } void AudioStreamInfo::dumpInfo() const { qCDebug(KDENLIVE_LOG) << "Info for audio stream " << m_audioStreamIndex << "\n\tChannels: " << m_channels << "\n\tSampling rate: " << m_samplingRate << "\n\tBit rate: " << m_bitRate; } void AudioStreamInfo::setAudioIndex(const std::shared_ptr &producer, int ix) { m_audioStreamIndex = ix; if (ix > -1) { int streams = producer->get_int("meta.media.nb_streams"); QList audioStreams; for (int i = 0; i < streams; ++i) { QByteArray propertyName = QStringLiteral("meta.media.%1.stream.type").arg(i).toLocal8Bit(); QString type = producer->get(propertyName.data()); if (type == QLatin1String("audio")) { audioStreams << i; } } if (audioStreams.count() > 1 && m_audioStreamIndex < audioStreams.count()) { m_ffmpegAudioIndex = audioStreams.indexOf(m_audioStreamIndex); } } } 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 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(';')); for (const QString &s : st) { m_activeStreams << s.toInt(); } } void AudioStreamInfo::renameStream(int ix, const QString streamName) { if (m_audioStreams.contains(ix)) { m_audioStreams.insert(ix, streamName); } } - diff --git a/src/mltcontroller/clippropertiescontroller.cpp b/src/mltcontroller/clippropertiescontroller.cpp index c8f36186b..2e6e807c4 100644 --- a/src/mltcontroller/clippropertiescontroller.cpp +++ b/src/mltcontroller/clippropertiescontroller.cpp @@ -1,1491 +1,1489 @@ /* Copyright (C) 2015 Jean-Baptiste Mardelle This file is part of Kdenlive. See www.kdenlive.org. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "clippropertiescontroller.h" #include "bin/model/markerlistmodel.hpp" #include "clipcontroller.h" #include "core.h" #include "dialogs/profilesdialog.h" #include "doc/kdenlivedoc.h" #include "kdenlivesettings.h" #include "profiles/profilerepository.hpp" #include "project/projectmanager.h" #include "timecodedisplay.h" #include