mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-18 16:32:33 +02:00
Add quality slider to import convert
This commit is contained in:
parent
8419a0b22d
commit
d153d3bbf7
@ -21,21 +21,18 @@ Item {
|
||||
clip: true
|
||||
|
||||
CreateWallpaperInit {
|
||||
onNext: {
|
||||
onNext: {
|
||||
root.wizardStarted()
|
||||
swipeView.currentIndex = 1
|
||||
createWallpaperVideoImportConvert.codec = codec
|
||||
createWallpaperVideoImportConvert.filePath = filePath
|
||||
ScreenPlay.create.createWallpaperStart(filePath,codec)
|
||||
ScreenPlay.create.createWallpaperStart(filePath, codec, quality)
|
||||
}
|
||||
}
|
||||
CreateWallpaperVideoImportConvert {
|
||||
id:createWallpaperVideoImportConvert
|
||||
onAbort:root.wizardExited()
|
||||
id: createWallpaperVideoImportConvert
|
||||
onAbort: root.wizardExited()
|
||||
}
|
||||
CreateWallpaperResult {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ Item {
|
||||
id: root
|
||||
signal next(var filePath, var codec)
|
||||
|
||||
property int quality: sliderQuality.slider.value
|
||||
ColumnLayout {
|
||||
spacing: 40
|
||||
|
||||
@ -71,6 +72,19 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
Common.Slider {
|
||||
id: sliderQuality
|
||||
iconSource: "qrc:/assets/icons/icon_settings.svg"
|
||||
headline: qsTr(
|
||||
"Quality slider. Greater value means better quality.")
|
||||
slider {
|
||||
from: 4
|
||||
value: 50
|
||||
to: 63
|
||||
stepSize: 1
|
||||
}
|
||||
Layout.preferredWidth: 400
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
@ -89,6 +103,7 @@ Item {
|
||||
margins: 20
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("Select file")
|
||||
highlighted: true
|
||||
|
@ -45,7 +45,7 @@ Create::Create()
|
||||
/*!
|
||||
\brief Starts the process.
|
||||
*/
|
||||
void Create::createWallpaperStart(QString videoPath, Create::VideoCodec codec)
|
||||
void Create::createWallpaperStart(QString videoPath, Create::VideoCodec codec, const int quality)
|
||||
{
|
||||
clearFfmpegOutput();
|
||||
videoPath = Util::toLocal(videoPath);
|
||||
@ -61,11 +61,22 @@ void Create::createWallpaperStart(QString videoPath, Create::VideoCodec codec)
|
||||
return;
|
||||
}
|
||||
setWorkingDir(dir.path() + "/" + folderName);
|
||||
QStringList codecs;
|
||||
codecs.append(codec == Create::VideoCodec::VP8 ? "vp8" : "vp9");
|
||||
|
||||
QString target_codec;
|
||||
switch (codec) {
|
||||
case Create::VideoCodec::VP8:
|
||||
target_codec = "vp8";
|
||||
break;
|
||||
case Create::VideoCodec::VP9:
|
||||
target_codec = "vp9";
|
||||
break;
|
||||
case Create::VideoCodec::AV1:
|
||||
target_codec = "av1";
|
||||
break;
|
||||
}
|
||||
|
||||
m_createImportVideoThread = new QThread(this);
|
||||
m_createImportVideo = new CreateImportVideo(videoPath, workingDir(), codecs);
|
||||
m_createImportVideo = new CreateImportVideo(videoPath, workingDir(), target_codec, quality);
|
||||
connect(m_createImportVideo, &CreateImportVideo::processOutput, this, [this](QString text) {
|
||||
appendFfmpegOutput(text + "\n");
|
||||
});
|
||||
|
@ -109,7 +109,7 @@ signals:
|
||||
|
||||
public slots:
|
||||
|
||||
void createWallpaperStart(QString videoPath, Create::VideoCodec codec);
|
||||
void createWallpaperStart(QString videoPath, Create::VideoCodec codec, const int quality);
|
||||
|
||||
void saveWallpaper(
|
||||
QString title,
|
||||
|
@ -28,12 +28,14 @@ CreateImportVideo::CreateImportVideo(QObject* parent)
|
||||
\brief Creates a CreateImportVideo object to be used in a different thread. A \a videoPath and a \a exportPath are
|
||||
needed for convertion.
|
||||
*/
|
||||
CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& exportPath, const QStringList& codecs, QObject* parent)
|
||||
CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& exportPath, const QString& codec, const int quality, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_quality(quality)
|
||||
{
|
||||
|
||||
m_videoPath = videoPath;
|
||||
m_exportPath = exportPath;
|
||||
m_codecs = codecs;
|
||||
m_codec = codec;
|
||||
m_process = std::make_unique<QProcess>(this);
|
||||
|
||||
m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + Util::executableEnding();
|
||||
@ -99,17 +101,31 @@ void CreateImportVideo::process()
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& codec : qAsConst(m_codecs)) {
|
||||
qInfo() << "createWallpaperVideo()";
|
||||
if (!createWallpaperVideo(codec) || QThread::currentThread()->isInterruptionRequested()) {
|
||||
emit abortAndCleanup();
|
||||
return;
|
||||
}
|
||||
qInfo() << "createWallpaperVideo()";
|
||||
if (!createWallpaperVideo() || QThread::currentThread()->isInterruptionRequested()) {
|
||||
emit abortAndCleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
emit createWallpaperStateChanged(ImportVideoState::Finished);
|
||||
}
|
||||
|
||||
void CreateImportVideo::processGif()
|
||||
{
|
||||
qInfo() << "createWallpaperImageThumbnailPreview()";
|
||||
if (!createWallpaperImageThumbnailPreview() || QThread::currentThread()->isInterruptionRequested()) {
|
||||
emit abortAndCleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
qInfo() << "createWallpaperImagePreview()";
|
||||
if (!createWallpaperImagePreview() || QThread::currentThread()->isInterruptionRequested()) {
|
||||
emit abortAndCleanup();
|
||||
return;
|
||||
}
|
||||
emit createWallpaperStateChanged(ImportVideoState::Finished);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Starts ffprobe and tries to parse the resulting json. If the video
|
||||
is a container that not contains the video length like webm or mkv
|
||||
@ -568,7 +584,7 @@ bool CreateImportVideo::createWallpaperImagePreview()
|
||||
\li Generally broken.
|
||||
\endlist
|
||||
*/
|
||||
bool CreateImportVideo::createWallpaperVideo(const QString& codec)
|
||||
bool CreateImportVideo::createWallpaperVideo()
|
||||
{
|
||||
emit createWallpaperStateChanged(ImportVideoState::ConvertingVideo);
|
||||
|
||||
@ -601,16 +617,16 @@ bool CreateImportVideo::createWallpaperVideo(const QString& codec)
|
||||
args.append("-i");
|
||||
args.append(m_videoPath);
|
||||
args.append("-c:v");
|
||||
if (codec == "vp8") {
|
||||
if (m_codec == "vp8")
|
||||
args.append("libvpx");
|
||||
}
|
||||
if (codec == "vp9") {
|
||||
if (m_codec == "vp9")
|
||||
args.append("libvpx-vp9");
|
||||
}
|
||||
if (m_codec == "av1")
|
||||
args.append("libaom-av1");
|
||||
args.append("-b:v");
|
||||
args.append("0");
|
||||
args.append("-crf");
|
||||
args.append("10");
|
||||
args.append(QString::number(m_quality));
|
||||
args.append("-pass");
|
||||
args.append("1");
|
||||
|
||||
@ -635,16 +651,16 @@ bool CreateImportVideo::createWallpaperVideo(const QString& codec)
|
||||
args.append("-i");
|
||||
args.append(m_videoPath);
|
||||
args.append("-c:v");
|
||||
if (codec == "vp8")
|
||||
if (m_codec == "vp8")
|
||||
args.append("libvpx");
|
||||
if (codec == "vp9")
|
||||
if (m_codec == "vp9")
|
||||
args.append("libvpx-vp9");
|
||||
if (codec == "av1")
|
||||
if (m_codec == "av1")
|
||||
args.append("libaom-av1");
|
||||
args.append("-b:v");
|
||||
args.append("0");
|
||||
args.append("-crf");
|
||||
args.append("10");
|
||||
args.append(QString::number(m_quality));
|
||||
args.append("-pass");
|
||||
args.append("2");
|
||||
const QFileInfo file(m_videoPath);
|
||||
|
@ -61,7 +61,7 @@ class CreateImportVideo : public QObject {
|
||||
public:
|
||||
CreateImportVideo() { }
|
||||
CreateImportVideo(QObject* parent = nullptr);
|
||||
explicit CreateImportVideo(const QString& videoPath, const QString& exportPath, const QStringList& codecs, QObject* parent = nullptr);
|
||||
explicit CreateImportVideo(const QString& videoPath, const QString& exportPath, const QString& codec, const int quality, QObject* parent = nullptr);
|
||||
|
||||
enum class ImportVideoState {
|
||||
Idle,
|
||||
@ -118,8 +118,9 @@ public:
|
||||
QString m_videoPath;
|
||||
QString m_exportPath;
|
||||
QString m_format;
|
||||
QStringList m_codecs;
|
||||
QString m_codec;
|
||||
|
||||
const int m_quality = 50;
|
||||
int m_numberOfFrames { 0 };
|
||||
int m_length { 0 };
|
||||
int m_framerate { 0 };
|
||||
@ -138,12 +139,13 @@ signals:
|
||||
|
||||
public slots:
|
||||
void process();
|
||||
void processGif();
|
||||
|
||||
bool createWallpaperInfo();
|
||||
bool createWallpaperVideoPreview();
|
||||
bool createWallpaperGifPreview();
|
||||
bool createWallpaperImagePreview();
|
||||
bool createWallpaperVideo(const QString& codec);
|
||||
bool createWallpaperVideo();
|
||||
bool extractWallpaperAudio();
|
||||
bool createWallpaperImageThumbnailPreview();
|
||||
|
||||
@ -161,9 +163,9 @@ public slots:
|
||||
|
||||
private:
|
||||
QString waitForFinished(
|
||||
const QStringList& args,
|
||||
const QProcess::ProcessChannelMode processChannelMode = QProcess::ProcessChannelMode::SeparateChannels,
|
||||
const Executable executable = Executable::FFMPEG);
|
||||
const QStringList& args,
|
||||
const QProcess::ProcessChannelMode processChannelMode = QProcess::ProcessChannelMode::SeparateChannels,
|
||||
const Executable executable = Executable::FFMPEG);
|
||||
|
||||
bool analyzeWebmReadFrames(const QJsonObject& obj);
|
||||
bool analyzeVideo(const QJsonObject& obj);
|
||||
|
Loading…
Reference in New Issue
Block a user