cleaner detection of audio streams

parent 7936b1b4
Pipeline #9371 passed with stage
in 17 minutes and 6 seconds
......@@ -21,6 +21,16 @@ AudioStreamInfo::AudioStreamInfo(const std::shared_ptr<Mlt::Producer> &producer,
, m_channels(2)
, m_bitRate(0)
{
// Fetch audio streams
int streams = producer->get_int("meta.media.nb_streams");
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")) {
m_audioStreams << ix;
}
}
if (audioStreamIndex > -1) {
QByteArray key;
key = QStringLiteral("meta.media.%1.codec.sample_fmt").arg(audioStreamIndex).toLocal8Bit();
......@@ -51,6 +61,11 @@ int AudioStreamInfo::channels() const
return m_channels;
}
int AudioStreamInfo::streams() const
{
return m_audioStreams.count();
}
int AudioStreamInfo::bitrate() const
{
return m_bitRate;
......
......@@ -12,6 +12,7 @@ the Free Software Foundation, either version 3 of the License, or
#define AUDIOSTREAMINFO_H
#include <QString>
#include <QList>
#include <memory>
#include <mlt++/Mlt.h>
......@@ -27,6 +28,7 @@ public:
int samplingRate() const;
int channels() const;
int streams() const;
int bitrate() const;
const QString &samplingFormat() const;
int audio_index() const;
......@@ -36,6 +38,7 @@ public:
private:
int m_audioStreamIndex;
QList <int> m_audioStreams;
int m_ffmpegAudioIndex;
int m_samplingRate;
int m_channels;
......
......@@ -29,7 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "profiles/profilerepository.hpp"
#include "project/projectmanager.h"
#include "timecodedisplay.h"
#include <audio/audioStreamInfo.h>
#include "widgets/choosecolorwidget.h"
#include <KDualAction>
......@@ -608,7 +608,6 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
hlay->addWidget(tbv);
hlay->addWidget(new QLabel(i18n("Audio stream")));
auto *audioStream = new QComboBox(this);
int ix = 1;
QMapIterator<int, QString> i(m_audioStreams);
while (i.hasNext()) {
i.next();
......@@ -642,7 +641,7 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
});
hlay->addWidget(audioStream);
vbox->addLayout(hlay);
// Audio sync
hlay = new QHBoxLayout;
hlay->addWidget(new QLabel(i18n("Audio sync")));
......@@ -663,7 +662,6 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
});
hlay->addWidget(spinSync);
vbox->addLayout(hlay);
}
// Colorspace
......@@ -976,7 +974,8 @@ void ClipPropertiesController::fillProperties()
// Find maximum stream index values
m_videoStreams.clear();
m_audioStreams.clear();
for (int ix = 0; ix < m_sourceProperties.get_int("meta.media.nb_streams"); ++ix) {
int aStreams = m_sourceProperties.get_int("meta.media.nb_streams");
for (int ix = 0; ix < aStreams; ++ix) {
char property[200];
snprintf(property, sizeof(property), "meta.media.%d.stream.type", ix);
QString type = m_sourceProperties.get(property);
......@@ -1065,6 +1064,8 @@ void ClipPropertiesController::fillProperties()
propertyMap.append({i18n("Colorspace"), ProfileRepository::getColorspaceDescription(colorspace)});
}
if (default_audio > -1) {
propertyMap.append({i18n("Audio streams"), QString::number(m_controller->audioInfo()->streams())});
QString codecInfo = QString("meta.media.%1.codec.").arg(default_audio);
QString property = codecInfo + QStringLiteral("long_name");
QString codec = m_sourceProperties.get(property.toUtf8().constData());
......
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