Commit 71eb0f28 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Transcode to edit friendly format: handle audio only and video only clips

parent 183ea547
Pipeline #144322 passed with stage
in 5 minutes and 24 seconds
......@@ -35,7 +35,10 @@ DVD NTSC 4:3=-f dvd -r 23.976 -vf scale=720:480 -aspect 4:3 -minrate 0 -maxrate
DVD NTSC 16:9=-f dvd -r 23.976 -vf scale=720:480 -aspect 16:9 -minrate 0 -maxrate 9000k -muxrate 10080000 -g 18 -bufsize 1835008 -packetsize 2048 -trellis 1 -me_range 63 -acodec ac3 -ab 192k -ar 48000 -vcodec mpeg2video -vb 6000k %1.vob;Dvd NTSC wide
[intermediate]
Lossy x264 I frame only=-f mp4 -codec:v libx264 -g 1 -bf 0 -crf 15 -preset medium -codec:a aac -ab 256k %1.mp4
Lossy x264 I frame only (NVidia GPU)=-f mp4 -vsync 0 -codec:v h264_nvenc -vb 0 -rc cbr -g 1 -bf 0 -codec:a aac -ab 256k %1.mp4
Intermediate DNxHR HQ (Large files)=-f mov -codec:a alac -codec:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p %1.mov
Lossless (Huge files)=-f matroska -codec:a pcm_f32le -codec:v utvideo -pix_fmt yuv422p %1.mkv
AAC (Audio only)=-vn -codec:a aac -ab 256k %1.m4a;audio
Lossy x264 I frame only=-f mp4 -codec:v libx264 -g 1 -bf 0 -crf 15 -preset medium -codec:a aac -ab 256k %1.mp4;av
Lossy x264 I frame only (Video only)=-f mp4 -codec:v libx264 -g 1 -bf 0 -crf 15 -preset medium -an %1.mp4;video
Lossy x264 I frame only (NVidia GPU)=-f mp4 -vsync 0 -codec:v h264_nvenc -vb 0 -rc cbr -g 1 -bf 0 -codec:a aac -ab 256k %1.mp4;av
Lossy x264 I frame only (NVidia GPU Video only)=-f mp4 -vsync 0 -codec:v h264_nvenc -vb 0 -rc cbr -g 1 -bf 0 -an %1.mp4;av
Intermediate DNxHR HQ (Large files)=-f mov -codec:a alac -codec:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p %1.mov;av
Lossless (Huge files)=-f matroska -codec:a pcm_f32le -codec:v utvideo -pix_fmt yuv422p %1.mkv;av
......@@ -4798,13 +4798,13 @@ void Bin::requestSelectionTranscoding()
if (m_transcodingDialog == nullptr) {
m_transcodingDialog = new TranscodeSeek(this);
connect(m_transcodingDialog, &QDialog::accepted, this, [&] () {
QMap<QString,QString> ids = m_transcodingDialog->ids();
QMap<QString,QStringList> ids = m_transcodingDialog->ids();
QString firstId = ids.firstKey();
QMapIterator<QString, QString> i(ids);
QMapIterator<QString, QStringList> i(ids);
while (i.hasNext()) {
i.next();
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(i.key());
TranscodeTask::start({ObjectType::BinClip,i.key().toInt()}, i.value(), m_transcodingDialog->preParams(), m_transcodingDialog->params(), -1, -1, true, clip.get(), false, false);
TranscodeTask::start({ObjectType::BinClip,i.key().toInt()}, i.value().first(), m_transcodingDialog->preParams(), m_transcodingDialog->params(i.value().at(1).toInt()), -1, -1, true, clip.get(), false, false);
}
m_transcodingDialog->deleteLater();
m_transcodingDialog = nullptr;
......@@ -4822,9 +4822,10 @@ void Bin::requestSelectionTranscoding()
const QString clipService = clip->getProducerProperty(QStringLiteral("mlt_service"));
if (clipService.startsWith(QLatin1String("avformat"))) {
QString resource = clip->clipUrl();
ClipType::ProducerType type = clip->clipType();
int integerFps = qRound(clip->originalFps());
QString suffix = QString("-%1fps").arg(integerFps);
m_transcodingDialog->addUrl(resource, id, suffix);
m_transcodingDialog->addUrl(resource, id, suffix, type);
}
}
}
......@@ -4836,13 +4837,13 @@ void Bin::requestTranscoding(const QString &url, const QString &id, bool checkPr
if (m_transcodingDialog == nullptr) {
m_transcodingDialog = new TranscodeSeek(this);
connect(m_transcodingDialog, &QDialog::accepted, this, [&, checkProfile] () {
QMap<QString,QString> ids = m_transcodingDialog->ids();
QMap<QString,QStringList> ids = m_transcodingDialog->ids();
QString firstId = ids.firstKey();
QMapIterator<QString, QString> i(ids);
QMapIterator<QString, QStringList> i(ids);
while (i.hasNext()) {
i.next();
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(i.key());
TranscodeTask::start({ObjectType::BinClip,i.key().toInt()}, i.value(), m_transcodingDialog->preParams(), m_transcodingDialog->params(), -1, -1, true, clip.get(), false, i.key() == firstId ? checkProfile : false);
TranscodeTask::start({ObjectType::BinClip,i.key().toInt()}, i.value().first(), m_transcodingDialog->preParams(), m_transcodingDialog->params(i.value().at(1).toInt()), -1, -1, true, clip.get(), false, i.key() == firstId ? checkProfile : false);
}
m_transcodingDialog->deleteLater();
m_transcodingDialog = nullptr;
......@@ -4860,10 +4861,15 @@ 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();
m_transcodingDialog->addUrl(resource, id, suffix);
ClipType::ProducerType type = clip->clipType();
m_transcodingDialog->addUrl(resource, id, suffix, type);
}
} else {
m_transcodingDialog->addUrl(url, id, suffix);
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->show();
}
......
......@@ -8,8 +8,8 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "transcodeseek.h"
#include "kdenlivesettings.h"
#include "kxmlgui_version.h"
#include <kxmlgui_version.h>
#include <KMessageBox>
#include <QFontDatabase>
#include <QStandardPaths>
......@@ -37,26 +37,109 @@ TranscodeSeek::~TranscodeSeek()
{
}
void TranscodeSeek::addUrl(const QString &file, const QString &id, const QString &suffix)
void TranscodeSeek::addUrl(const QString &file, const QString &id, const QString &suffix, ClipType::ProducerType type)
{
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 (listWidget->count() == 1) {
if (type == ClipType::Audio) {
if (!m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";audio"))) {
// Switch to audio only profile
QMapIterator<QString, QString> i(m_encodeParams);
while (i.hasNext()) {
i.next();
if (i.value().endsWith(QLatin1String(";audio"))) {
int ix = encodingprofiles->findText(i.key());
if (ix > -1) {
encodingprofiles->setCurrentIndex(ix);
break;
}
}
}
}
} else if (type == ClipType::Video) {
if (!m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";video"))) {
// Switch to video only profile
QMapIterator<QString, QString> i(m_encodeParams);
while (i.hasNext()) {
i.next();
if (i.value().endsWith(QLatin1String(";video"))) {
int ix = encodingprofiles->findText(i.key());
if (ix > -1) {
encodingprofiles->setCurrentIndex(ix);
break;
}
}
}
}
}
} else {
if ((type != ClipType::Video && m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";video"))) || (type != ClipType::Audio && m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";audio")))) {
// Switch back to an AV profile
QMapIterator<QString, QString> i(m_encodeParams);
while (i.hasNext()) {
i.next();
if (i.value().endsWith(QLatin1String(";av"))) {
int ix = encodingprofiles->findText(i.key());
if (ix > -1) {
encodingprofiles->setCurrentIndex(ix);
break;
}
}
}
}
}
}
QMap<QString,QString> TranscodeSeek::ids() const
QMap<QString,QStringList> TranscodeSeek::ids() const
{
QMap<QString,QString> urls;
QMap<QString,QStringList> urls;
for (int i = 0; i < listWidget->count(); i++) {
urls.insert(listWidget->item(i)->data(Qt::UserRole).toString(), listWidget->item(i)->data(Qt::UserRole + 1).toString());
QListWidgetItem *item = listWidget->item(i);
urls.insert(item->data(Qt::UserRole).toString(), {item->data(Qt::UserRole + 1).toString(), item->data(Qt::UserRole + 2).toString()});
}
return urls;
}
QString TranscodeSeek::params() const
QString TranscodeSeek::params(int clipType) const
{
KdenliveSettings::setTranscodeFriendly(encodingprofiles->currentText());
return m_encodeParams.value(encodingprofiles->currentText());
switch (clipType) {
case ClipType::Audio: {
if (!m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";audio"))) {
// Switch to audio only profile
QMapIterator<QString, QString> i(m_encodeParams);
while (i.hasNext()) {
i.next();
if (i.value().endsWith(QLatin1String(";audio"))) {
return i.value().section(QLatin1Char(';'), 0, -2);
}
}
}
break;
}
case ClipType::Video: {
if (!m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";video"))) {
// Switch to video only profile
QMapIterator<QString, QString> i(m_encodeParams);
while (i.hasNext()) {
i.next();
if (i.value().endsWith(QLatin1String(";video"))) {
return i.value().section(QLatin1Char(';'), 0, -2);
}
}
}
break;
}
default:
break;
}
if (m_encodeParams.value(encodingprofiles->currentText()).endsWith(QLatin1String(";av"))) {
// Only store selected av preset
KdenliveSettings::setTranscodeFriendly(encodingprofiles->currentText());
}
return m_encodeParams.value(encodingprofiles->currentText()).section(QLatin1Char(';'), 0, -2);
}
QString TranscodeSeek::preParams() const
......
......@@ -9,7 +9,9 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#ifndef TRANSCODESEEK_H
#define TRANSCODESEEK_H
#include "definitions.h"
#include "ui_transcodeseekable_ui.h"
#include <QUrl>
#include <QProcess>
......@@ -21,9 +23,9 @@ public:
TranscodeSeek(QWidget *parent = nullptr);
~TranscodeSeek() override;
void addUrl(const QString &file, const QString &id, const QString &suffix);
QMap<QString,QString> ids() const;
QString params() const;
void addUrl(const QString &file, const QString &id, const QString &suffix, ClipType::ProducerType type);
QMap<QString,QStringList> ids() const;
QString params(int clipType) const;
QString preParams() const;
private:
......
Supports Markdown
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