Commit b62462a4 authored by Julius Künzel's avatar Julius Künzel
Browse files

Partly Revert 19b9a0b7 since it caused trouble

Also it is not useful anymore after
fa33bbf2

This partly reverts commit 19b9a0b7
"GIT_SILENT Move codec checking to MltConnection to avoid duplicated
code"
parent 5cd80a28
......@@ -407,21 +407,6 @@ std::unique_ptr<Mlt::Repository> &Core::getMltRepository()
return MltConnection::self()->getMltRepository();
}
QStringList Core::mltSupportedFormats()
{
return MltConnection::self()->supportedFormats();
}
QStringList Core::mltACodecs()
{
return MltConnection::self()->aCodecs();
}
QStringList Core::mltVCodecs()
{
return MltConnection::self()->vCodecs();
}
std::unique_ptr<ProfileModel> &Core::getCurrentProfile() const
{
return ProfileRepository::get()->getProfile(m_currentProfile);
......
......@@ -131,10 +131,6 @@ public:
/** @brief Returns a pointer to MLT's repository */
std::unique_ptr<Mlt::Repository> &getMltRepository();
QStringList mltSupportedFormats();
QStringList mltACodecs();
QStringList mltVCodecs();
/** @brief Returns a pointer to the current profile */
std::unique_ptr<ProfileModel> &getCurrentProfile() const;
const QString &getCurrentProfilePath() const;
......
......@@ -249,6 +249,7 @@ RenderWidget::RenderWidget(bool enableProxy, QWidget *parent)
connect(m_view.export_audio, &QCheckBox::stateChanged, this, &RenderWidget::slotUpdateAudioLabel);
m_view.export_audio->setCheckState(Qt::PartiallyChecked);
checkCodecs();
parseProfiles();
parseScriptFiles();
m_view.running_jobs->setUniformRowHeights(false);
......@@ -1841,7 +1842,7 @@ void RenderWidget::refreshView()
}
// Make sure the selected profile uses an installed avformat codec / format
if (!pCore->mltSupportedFormats().isEmpty()) {
if (!m_supportedFormats.isEmpty()) {
QString format;
if (params.startsWith(QLatin1String("f="))) {
format = params.section(QStringLiteral("f="), 1, 1);
......@@ -1850,7 +1851,7 @@ void RenderWidget::refreshView()
}
if (!format.isEmpty()) {
format = format.section(QLatin1Char(' '), 0, 0).toLower();
if (!pCore->mltSupportedFormats().contains(format)) {
if (!m_supportedFormats.contains(format)) {
item->setData(0, ErrorRole, i18n("Unsupported video format: %1", format));
item->setIcon(0, brokenIcon);
item->setForeground(0, disabled);
......@@ -1858,7 +1859,6 @@ void RenderWidget::refreshView()
}
}
}
// check for missing audio codecs
QString format;
if (params.startsWith(QLatin1String("acodec="))) {
......@@ -1868,14 +1868,14 @@ void RenderWidget::refreshView()
}
if (!format.isEmpty()) {
format = format.section(QLatin1Char(' '), 0, 0).toLower();
if (!pCore->mltACodecs().contains(format)) {
if (!m_acodecsList.contains(format)) {
item->setData(0, ErrorRole, i18n("Unsupported audio codec: %1", format));
item->setIcon(0, brokenIcon);
item->setForeground(0, disabled);
item->setBackground(0, disabledbg);
}
}
// check for missing video codecs
// check for missing audio codecs
format.clear();
if (params.startsWith(QLatin1String("vcodec="))) {
format = params.section(QStringLiteral("vcodec="), 1, 1);
......@@ -1884,13 +1884,14 @@ void RenderWidget::refreshView()
}
if (!format.isEmpty()) {
format = format.section(QLatin1Char(' '), 0, 0).toLower();
if (!pCore->mltVCodecs().contains(format)) {
if (!m_vcodecsList.contains(format)) {
item->setData(0, ErrorRole, i18n("Unsupported video codec: %1", format));
item->setIcon(0, brokenIcon);
item->setForeground(0, disabled);
continue;
}
}
if (params.contains(QStringLiteral(" profile=")) || params.startsWith(QLatin1String("profile="))) {
// changed in MLT commit d8a3a5c9190646aae72048f71a39ee7446a3bd45
// (https://github.com/mltframework/mlt/commit/d8a3a5c9190646aae72048f71a39ee7446a3bd45)
......@@ -2214,11 +2215,11 @@ void RenderWidget::parseFile(const QString &exportFile, bool editable)
QDomNodeList groups = doc.elementsByTagName(QStringLiteral("group"));
QTreeWidgetItem *item = nullptr;
bool replaceVorbisCodec = false;
if (pCore->mltACodecs().contains(QStringLiteral("libvorbis"))) {
if (m_acodecsList.contains(QStringLiteral("libvorbis"))) {
replaceVorbisCodec = true;
}
bool replaceLibfaacCodec = false;
if (pCore->mltACodecs().contains(QStringLiteral("libfaac"))) {
if (m_acodecsList.contains(QStringLiteral("libfaac"))) {
replaceLibfaacCodec = true;
}
......@@ -3120,6 +3121,37 @@ void RenderWidget::adjustSpeed(int speedIndex)
}
}
void RenderWidget::checkCodecs()
{
Mlt::Profile p;
auto *consumer = new Mlt::Consumer(p, "avformat");
if (consumer) {
consumer->set("vcodec", "list");
consumer->set("acodec", "list");
consumer->set("f", "list");
consumer->start();
m_vcodecsList.clear();
Mlt::Properties vcodecs(mlt_properties(consumer->get_data("vcodec")));
m_vcodecsList.reserve(vcodecs.count());
for (int i = 0; i < vcodecs.count(); ++i) {
m_vcodecsList << QString(vcodecs.get(i));
}
m_acodecsList.clear();
Mlt::Properties acodecs(mlt_properties(consumer->get_data("acodec")));
m_acodecsList.reserve(acodecs.count());
for (int i = 0; i < acodecs.count(); ++i) {
m_acodecsList << QString(acodecs.get(i));
}
m_supportedFormats.clear();
Mlt::Properties formats(mlt_properties(consumer->get_data("f")));
m_supportedFormats.reserve(formats.count());
for (int i = 0; i < formats.count(); ++i) {
m_supportedFormats << QString(formats.get(i));
}
delete consumer;
}
}
void RenderWidget::slotProxyWarn(bool enableProxy)
{
errorMessage(ProxyWarning, enableProxy ? i18n("Rendering using low quality proxy") : QString());
......
......@@ -208,6 +208,10 @@ private:
QMap<int, QString> m_errorMessages;
std::weak_ptr<MarkerListModel> m_guidesModel;
QStringList m_acodecsList;
QStringList m_vcodecsList;
QStringList m_supportedFormats;
#ifdef KF5_USE_PURPOSE
Purpose::Menu *m_shareMenu;
#endif
......@@ -222,6 +226,7 @@ private:
bool saveProfile(QDomElement newprofile);
/** @brief Create a rendering profile from MLT preset. */
QTreeWidgetItem *loadFromMltPreset(const QString &groupName, const QString &path, const QString &profileName);
void checkCodecs();
void prepareRendering(bool delayedRendering, const QString &chapterFile);
void generateRenderFiles(QDomDocument doc, const QString &playlistPath, int in, int out, bool delayedRendering);
......
......@@ -82,7 +82,6 @@ MltConnection::MltConnection(const QString &mltPath)
mlt_log_set_level(MLT_LOG_WARNING);
mlt_log_set_callback(mlt_log_handler);
refreshLumas();
reloadCodecLists();
}
void MltConnection::construct(const QString &mltPath)
......@@ -310,34 +309,3 @@ void MltConnection::refreshLumas()
allImagefiles.removeDuplicates();
QtConcurrent::run(pCore.get(), &Core::buildLumaThumbs, allImagefiles);
}
void MltConnection::reloadCodecLists()
{
Mlt::Profile p;
auto *consumer = new Mlt::Consumer(p, "avformat");
if (consumer) {
consumer->set("vcodec", "list");
consumer->set("acodec", "list");
consumer->set("f", "list");
consumer->start();
m_vCodecsList.clear();
Mlt::Properties vcodecs(mlt_properties(consumer->get_data("vcodec")));
m_vCodecsList.reserve(vcodecs.count());
for (int i = 0; i < vcodecs.count(); ++i) {
m_vCodecsList << QString(vcodecs.get(i));
}
m_aCodecsList.clear();
Mlt::Properties acodecs(mlt_properties(consumer->get_data("acodec")));
m_aCodecsList.reserve(acodecs.count());
for (int i = 0; i < acodecs.count(); ++i) {
m_aCodecsList << QString(acodecs.get(i));
}
m_supportedFormats.clear();
Mlt::Properties formats(mlt_properties(consumer->get_data("f")));
m_supportedFormats.reserve(formats.count());
for (int i = 0; i < formats.count(); ++i) {
m_supportedFormats << QString(formats.get(i));
}
delete consumer;
}
}
......@@ -7,7 +7,6 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#define MLTCONNECTION_H
#include <QString>
#include <QStringList>
#include <memory>
namespace Mlt {
......@@ -36,10 +35,6 @@ public:
*/
static void refreshLumas();
QStringList vCodecs() { return m_vCodecsList; };
QStringList aCodecs() { return m_aCodecsList; };
QStringList supportedFormats() { return m_supportedFormats; };
protected:
/** @brief Open connection to the MLT framework
This constructor should be called only once
......@@ -47,29 +42,17 @@ protected:
MltConnection(const QString &mltPath);
/** @brief Locates the MLT environment.
* @param mltPath (optional) path to MLT environment
* @param mltPath (optional) path to MLT environment
*
* It tries to set the paths of the MLT profiles and renderer, using
* mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
* user. It doesn't fill any list of profiles, while its name suggests so. */
* It tries to set the paths of the MLT profiles and renderer, using
* mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the
* user. It doesn't fill any list of profiles, while its name suggests so. */
void locateMeltAndProfilesPath(const QString &mltPath = QString());
static std::unique_ptr<MltConnection> m_self;
/** @brief The MLT repository, useful for filter/producer requests */
std::unique_ptr<Mlt::Repository> m_repository;
private:
/** @brief Checks for available codecs and formats using the avformat producer.
*
* Results are written to m_vCodecsList, m_aCodecsList and m_supportedFormats
* and can be accessed through @ref vCodecs() @ref aCodecs() and @ref supportedFormats()
*/
void reloadCodecLists();
QStringList m_vCodecsList;
QStringList m_aCodecsList;
QStringList m_supportedFormats;
};
#endif
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