Commit 511b75ff authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Propose to transcode clips that don't have a valid duration instead of failing.

BUG: 430262
parent bc104195
Pipeline #43835 passed with stage
in 10 minutes and 9 seconds
......@@ -80,6 +80,7 @@ void Core::build(bool isAppImage, const QString &MltPath)
qRegisterMetaType<audioShortVector>("audioShortVector");
qRegisterMetaType<QVector<double>>("QVector<double>");
qRegisterMetaType<QList<QAction*>>("QList<QAction*>");
qRegisterMetaType<MessageType>("MessageType");
qRegisterMetaType<stringMap>("stringMap");
qRegisterMetaType<audioByteArray>("audioByteArray");
......@@ -991,3 +992,9 @@ void Core::temporaryUnplug(QList<int> clipIds, bool hide)
{
pCore->window()->getMainTimeline()->controller()->temporaryUnplug(clipIds, hide);
}
void Core::transcodeFile(const QString url)
{
qDebug()<<"=== TRANSCODING: "<<url;
pCore->window()->slotTranscode({url});
}
......@@ -239,7 +239,8 @@ public:
void temporaryUnplug(QList<int> clipIds, bool hide);
/** @brief Returns the current doc's subtitle model. */
std::shared_ptr<SubtitleModel> getSubtitleModel(bool enforce = false);
/** @brief Transcode a video file. */
void transcodeFile(const QString url);
KSharedDataCache audioThumbCache;
private:
......
......@@ -419,21 +419,14 @@ bool LoadJob::startJob()
m_producer.reset();
}
qDebug()<<"=== MAX DURATION: "<<INT_MAX<<", DURATION: "<<(INT_MAX / 25 / 60);
QAction *ac = new QAction(i18n("Transcode"), this);
connect(ac, &QAction::triggered, [&]() {
pCore->transcodeFile(m_resource);
});
QList<QAction*>actions = {ac};
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot get duration for file %1", m_resource)),
Q_ARG(int, (int)KMessageWidget::Warning));
m_errorMessage.append(i18n("ERROR: Could not load clip %1: producer is invalid", m_resource));
return false;
}
if (m_producer->get_length() == INT_MAX && m_producer->get("eof") == QLatin1String("loop")) {
// This is a live source or broken clip
m_done = true;
m_successful = false;
if (m_producer) {
m_producer.reset();
}
qDebug()<<"=== MAX DURATION: "<<INT_MAX<<", DURATION: "<<(INT_MAX / 25 / 60);
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot get duration for file %1", m_resource)),
Q_ARG(int, (int)KMessageWidget::Warning));
Q_ARG(int, (int)KMessageWidget::Warning), Q_ARG(QList<QAction*>, actions));
m_errorMessage.append(i18n("ERROR: Could not load clip %1: producer is invalid", m_resource));
return false;
}
......
......@@ -299,6 +299,7 @@ public slots:
/** @brief Open the online services search dialog. */
void slotDownloadResources();
void slotEditSubtitle(QMap<QString, QString> subProperties = {});
void slotTranscode(const QStringList &urls = QStringList());
private slots:
/** @brief Shows the shortcut dialog. */
......@@ -426,7 +427,6 @@ private slots:
void slotUpdateClipType(QAction *action);
void slotUpdateTimelineView(QAction *action);
void slotShowTimeline(bool show);
void slotTranscode(const QStringList &urls = QStringList());
void slotTranscodeClip();
/** @brief Archive project: creates a copy of the project file with all clips in a new folder. */
void slotArchiveProject();
......
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