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