Commit 814dbae1 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Transcoding: display info for files requiring transcoding, improve handling of...

Transcoding: display info for files requiring transcoding, improve handling of audio only/video only files
parent 71eb0f28
Pipeline #144883 passed with stage
in 5 minutes and 52 seconds
......@@ -4825,14 +4825,14 @@ void Bin::requestSelectionTranscoding()
ClipType::ProducerType type = clip->clipType();
int integerFps = qRound(clip->originalFps());
QString suffix = QString("-%1fps").arg(integerFps);
m_transcodingDialog->addUrl(resource, id, suffix, type);
m_transcodingDialog->addUrl(resource, id, suffix, type, QString());
}
}
}
m_transcodingDialog->show();
}
void Bin::requestTranscoding(const QString &url, const QString &id, bool checkProfile, const QString suffix)
void Bin::requestTranscoding(const QString &url, const QString &id, int type, bool checkProfile, const QString &suffix, const QString &message)
{
if (m_transcodingDialog == nullptr) {
m_transcodingDialog = new TranscodeSeek(this);
......@@ -4861,14 +4861,12 @@ void Bin::requestTranscoding(const QString &url, const QString &id, bool checkPr
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(id);
if (clip) {
QString resource = clip->clipUrl();
ClipType::ProducerType type = clip->clipType();
m_transcodingDialog->addUrl(resource, id, suffix, type);
m_transcodingDialog->addUrl(resource, id, suffix, (ClipType::ProducerType) type, message);
}
} else {
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(id);
if (clip) {
ClipType::ProducerType type = clip->clipType();
m_transcodingDialog->addUrl(url, id, suffix, type);
m_transcodingDialog->addUrl(url, id, suffix, (ClipType::ProducerType) type, message);
}
}
m_transcodingDialog->show();
......
......@@ -461,7 +461,7 @@ public slots:
/** @brief Check if a clip profile matches project, propose switch otherwise */
void slotCheckProfile(const QString &binId);
/** @brief A non seekable clip was added to project, propose transcoding */
void requestTranscoding(const QString &url, const QString &id, bool checkProfile, const QString suffix = QString());
void requestTranscoding(const QString &url, const QString &id, int type, bool checkProfile, const QString &suffix = QString(), const QString &message = QString());
/** @brief Display the transcode to edit friendly format for currenly selected bin clips */
void requestSelectionTranscoding();
/** @brief Build the project bin audio/video icons according to color theme */
......
......@@ -474,13 +474,23 @@ void ClipLoadTask::run()
abort();
return;
}
const QString mltService = producer->get("mlt_service");
if (producer->get_length() == INT_MAX && producer->get("eof") == QLatin1String("loop")) {
// This is a live source or broken clip
// Check for AV
ClipType::ProducerType cType = type;
if (producer) {
if (mltService.startsWith(QLatin1String("avformat")) && cType == ClipType::Unknown) {
// Check if it is an audio or video only clip
if (producer->get_int("video_index") == -1) {
cType = ClipType::Audio;
} else if (producer->get_int("audio_index") == -1) {
cType = ClipType::Video;
}
}
producer.reset();
}
qDebug()<<"=== MAX DURATION: "<<INT_MAX<<", DURATION: "<<(INT_MAX / 25 / 60)<<"; RES: "<<resource;
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, QString::number(m_owner.second)), Q_ARG(bool, pCore->bin()->shouldCheckProfile));
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, QString::number(m_owner.second)), Q_ARG(int, cType), Q_ARG(bool, pCore->bin()->shouldCheckProfile), Q_ARG(QString, QString()), Q_ARG(QString, i18n("Duration of file <b>%1</b> cannot be determined.", QFileInfo(resource).fileName())));
if (pCore->bin()->shouldCheckProfile) {
pCore->bin()->shouldCheckProfile = false;
}
......@@ -502,7 +512,6 @@ void ClipLoadTask::run()
clipOut = m_xml.attribute(QStringLiteral("out")).toInt();
}
// setup length here as otherwise default length (currently 15000 frames in MLT) will be taken even if outpoint is larger
const QString mltService = producer->get("mlt_service");
QMimeDatabase db;
const QString mime = db.mimeTypeForFile(resource).name();
const bool isGif = mime.contains(QLatin1String("image/gif"));
......@@ -611,7 +620,16 @@ void ClipLoadTask::run()
if (checkProfile) {
pCore->bin()->shouldCheckProfile = false;
}
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, QString::number(m_owner.second)), Q_ARG(bool, checkProfile));
ClipType::ProducerType cType = type;
if (cType == ClipType::Unknown) {
// Check if it is an audio or video only clip
if (!hasVideo) {
cType = ClipType::Audio;
} else if (!hasAudio) {
cType = ClipType::Video;
}
}
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, QString::number(m_owner.second)), Q_ARG(int, cType), Q_ARG(bool, checkProfile), Q_ARG(QString, QString()), Q_ARG(QString, i18n("File <b>%1</b> is not seekable.", QFileInfo(resource).fileName())));
}
// check if there are multiple streams
......@@ -645,7 +663,16 @@ void ClipLoadTask::run()
int integerFps = qRound(fps);
adjustedFpsString = QString("-%1fps").arg(integerFps);
}
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, QString::number(m_owner.second)), Q_ARG(bool, checkProfile), Q_ARG(QString, adjustedFpsString));
ClipType::ProducerType cType = type;
if (cType == ClipType::Unknown) {
// Check if it is an audio or video only clip
if (!hasVideo) {
cType = ClipType::Audio;
} else if (!hasAudio) {
cType = ClipType::Video;
}
}
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, resource), Q_ARG(QString, QString::number(m_owner.second)), Q_ARG(int, cType), Q_ARG(bool, checkProfile), Q_ARG(QString, adjustedFpsString), Q_ARG(QString, i18n("File <b>%1</b> has a variable frame rate.", QFileInfo(resource).fileName())));
}
if (fps <= 0 && !m_isCanceled) {
......
......@@ -31,18 +31,33 @@ TranscodeSeek::TranscodeSeek(QWidget *parent)
encodingprofiles->setCurrentIndex(ix);
}
autorotate->setChecked(KdenliveSettings::transcodeFriendlyRotate());
messagewidget->setVisible(false);
}
TranscodeSeek::~TranscodeSeek()
{
}
void TranscodeSeek::addUrl(const QString &file, const QString &id, const QString &suffix, ClipType::ProducerType type)
void TranscodeSeek::addUrl(const QString &file, const QString &id, const QString &suffix, ClipType::ProducerType type, const QString &message)
{
QListWidgetItem *it = new QListWidgetItem(file, listWidget);
it->setData(Qt::UserRole, id);
it->setData(Qt::UserRole + 1, suffix);
it->setData(Qt::UserRole + 2, QString::number(type));
if (!message.isEmpty()) {
if (messagewidget->text().isEmpty()) {
messagewidget->setText(message);
messagewidget->animatedShow();
} else {
QString mText = messagewidget->text();
if (mText.length() < 120) {
mText.append(QStringLiteral("<br/>"));
mText.append(message);
messagewidget->setText(mText);
messagewidget->animatedShow();
}
}
}
if (listWidget->count() == 1) {
if (type == ClipType::Audio) {
if (!m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";audio"))) {
......
......@@ -23,7 +23,7 @@ public:
TranscodeSeek(QWidget *parent = nullptr);
~TranscodeSeek() override;
void addUrl(const QString &file, const QString &id, const QString &suffix, ClipType::ProducerType type);
void addUrl(const QString &file, const QString &id, const QString &suffix, ClipType::ProducerType type, const QString &message);
QMap<QString,QStringList> ids() const;
QString params(int clipType) const;
QString preParams() const;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>498</width>
<height>270</height>
<width>416</width>
<height>269</height>
</rect>
</property>
<property name="windowTitle">
......@@ -21,7 +21,14 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Convert to</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="encodingprofiles">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
......@@ -44,14 +51,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Convert to</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -61,15 +61,32 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="autorotate">
<property name="text">
<string>Disable autorotate</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="KMessageWidget" name="messagewidget">
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="closeButtonVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KMessageWidget</class>
<extends>QFrame</extends>
<header>kmessagewidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
......
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