mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Cleanup converting video
This commit is contained in:
parent
fb0ab7aead
commit
5692d6cf6d
@ -236,7 +236,7 @@ Item {
|
|||||||
Connections {
|
Connections {
|
||||||
target: screenPlayCreate
|
target: screenPlayCreate
|
||||||
onCreateWallpaperStateChanged: {
|
onCreateWallpaperStateChanged: {
|
||||||
if (state === Create.State.ConvertingVideoFinished) {
|
if (state === CreateImportVideo.State.ConvertingVideoFinished) {
|
||||||
btnFinish.state = "enabled"
|
btnFinish.state = "enabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ Item {
|
|||||||
target: screenPlayCreate
|
target: screenPlayCreate
|
||||||
|
|
||||||
onCreateWallpaperStateChanged: {
|
onCreateWallpaperStateChanged: {
|
||||||
if (state === Create.State.ConvertingPreviewImageFinished) {
|
if (state === CreateImportVideo.State.ConvertingPreviewImageFinished) {
|
||||||
imgPreview.source = "file:///"
|
imgPreview.source = "file:///"
|
||||||
+ screenPlayCreate.workingDir + "/preview.png"
|
+ screenPlayCreate.workingDir + "/preview.png"
|
||||||
imgPreview.visible = true
|
imgPreview.visible = true
|
||||||
@ -100,30 +100,30 @@ Item {
|
|||||||
"Converting Video preview mp4")
|
"Converting Video preview mp4")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state === Create.State.ConvertingPreviewVideo) {
|
if (state === CreateImportVideo.State.ConvertingPreviewVideo) {
|
||||||
txtConvert.text = qsTr(
|
txtConvert.text = qsTr(
|
||||||
"Generating preview video...")
|
"Generating preview video...")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state === Create.State.ConvertingPreviewGif) {
|
if (state === CreateImportVideo.State.ConvertingPreviewGif) {
|
||||||
txtConvert.text = qsTr(
|
txtConvert.text = qsTr(
|
||||||
"Generating preview gif...")
|
"Generating preview gif...")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state === Create.State.ConvertingPreviewGifFinished) {
|
if (state === CreateImportVideo.State.ConvertingPreviewGifFinished) {
|
||||||
imgPreview.source = "file:///"
|
imgPreview.source = "file:///"
|
||||||
+ screenPlayCreate.workingDir + "/preview.gif"
|
+ screenPlayCreate.workingDir + "/preview.gif"
|
||||||
imgPreview.visible = true
|
imgPreview.visible = true
|
||||||
imgPreview.playing = true
|
imgPreview.playing = true
|
||||||
}
|
}
|
||||||
if (state === Create.State.ConvertingAudio) {
|
if (state === CreateImportVideo.State.ConvertingAudio) {
|
||||||
txtConvert.text = qsTr("Converting Audio...")
|
txtConvert.text = qsTr("Converting Audio...")
|
||||||
}
|
}
|
||||||
if (state === Create.State.ConvertingVideo) {
|
if (state === CreateImportVideo.State.ConvertingVideo) {
|
||||||
txtConvert.text = qsTr("Converting Video...")
|
txtConvert.text = qsTr("Converting Video...")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state === Create.State.Finished) {
|
if (state === CreateImportVideo.State.Finished) {
|
||||||
imgSuccess.source = "file:///"
|
imgSuccess.source = "file:///"
|
||||||
+ screenPlayCreate.workingDir + "/preview.gif"
|
+ screenPlayCreate.workingDir + "/preview.gif"
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ Item {
|
|||||||
Connections {
|
Connections {
|
||||||
target: screenPlayCreate
|
target: screenPlayCreate
|
||||||
onCreateWallpaperStateChanged: {
|
onCreateWallpaperStateChanged: {
|
||||||
if (state === Create.State.ConvertingVideoFinished) {
|
if (state === CreateImportVideo.State.ConvertingVideoFinished) {
|
||||||
btnFinish.state = "enabled"
|
btnFinish.state = "enabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import QtQuick.Controls 2.2
|
|||||||
import QtQuick.Controls.Material 2.3
|
import QtQuick.Controls.Material 2.3
|
||||||
import Qt.labs.platform 1.0
|
import Qt.labs.platform 1.0
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
import net.aimber.create 1.0
|
import net.aimber.create 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@ -34,10 +35,10 @@ Item {
|
|||||||
target: screenPlayCreate
|
target: screenPlayCreate
|
||||||
onCreateWallpaperStateChanged: {
|
onCreateWallpaperStateChanged: {
|
||||||
|
|
||||||
if (state === Create.State.ConvertingPreviewGifError
|
if (state === CreateImportVideo.State.ConvertingPreviewGifError
|
||||||
|| state === Create.State.ConvertingPreviewVideoError
|
|| state === CreateImportVideo.State.ConvertingPreviewVideoError
|
||||||
|| state === Create.State.ConvertingPreviewImageError
|
|| state === CreateImportVideo.State.ConvertingPreviewImageError
|
||||||
|| state === Create.State.AnalyseVideoError) {
|
|| state === CreateImportVideo.State.AnalyseVideoError) {
|
||||||
createNew.state = "error"
|
createNew.state = "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ Create::Create(Settings* st, QMLUtilities* util, QObject* parent)
|
|||||||
|
|
||||||
qRegisterMetaType<CreateImportVideo::State>();
|
qRegisterMetaType<CreateImportVideo::State>();
|
||||||
qmlRegisterType<Create>("net.aimber.create", 1, 0, "Create");
|
qmlRegisterType<Create>("net.aimber.create", 1, 0, "Create");
|
||||||
|
qmlRegisterType<CreateImportVideo>("net.aimber.create", 1, 0, "Create");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Create::copyProject(QString relativeProjectPath, QString toPath)
|
void Create::copyProject(QString relativeProjectPath, QString toPath)
|
||||||
@ -69,23 +70,14 @@ void Create::createWallpaperStart(QString videoPath)
|
|||||||
m_createWallpaperData.exportPath = dir.path() + "/" + folderName;
|
m_createWallpaperData.exportPath = dir.path() + "/" + folderName;
|
||||||
setWorkingDir(m_createWallpaperData.exportPath);
|
setWorkingDir(m_createWallpaperData.exportPath);
|
||||||
|
|
||||||
auto* thread = new QThread;
|
m_createImportVideoThread = new QThread;
|
||||||
m_createImportVideo = new CreateImportVideo(videoPath, m_createWallpaperData.exportPath);
|
m_createImportVideo = new CreateImportVideo(videoPath, m_createWallpaperData.exportPath);
|
||||||
connect(m_createImportVideo, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
|
//connect(m_createImportVideo, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
|
||||||
connect(thread, &QThread::started, m_createImportVideo, &CreateImportVideo::process);
|
connect(m_createImportVideoThread, &QThread::started, m_createImportVideo, &CreateImportVideo::process);
|
||||||
connect(m_createImportVideo, &CreateImportVideo::finished, thread, &QThread::quit);
|
connect(m_createImportVideo, &CreateImportVideo::finished, m_createImportVideoThread, &QThread::quit);
|
||||||
connect(m_createImportVideo, &CreateImportVideo::finished, m_createImportVideo, &QObject::deleteLater);
|
connect(m_createImportVideo, &CreateImportVideo::finished, m_createImportVideo, &QObject::deleteLater);
|
||||||
connect(thread, &QThread::finished, thread, &QObject::deleteLater);
|
connect(m_createImportVideoThread, &QThread::finished, m_createImportVideoThread, &QObject::deleteLater);
|
||||||
m_createImportVideo->moveToThread(thread);
|
connect(m_createImportVideoThread, &QThread::destroyed, this, [this]() {
|
||||||
thread->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Create::abortAndCleanup()
|
|
||||||
{
|
|
||||||
emit abortCreateWallpaper();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QDir exportPath(m_createWallpaperData.exportPath);
|
QDir exportPath(m_createWallpaperData.exportPath);
|
||||||
|
|
||||||
if (exportPath.exists()) {
|
if (exportPath.exists()) {
|
||||||
@ -96,4 +88,13 @@ void Create::abortAndCleanup()
|
|||||||
qDebug() << "cleanup " << m_createWallpaperData.exportPath;
|
qDebug() << "cleanup " << m_createWallpaperData.exportPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
m_createImportVideo->moveToThread(m_createImportVideoThread);
|
||||||
|
m_createImportVideoThread->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Create::abortAndCleanup()
|
||||||
|
{
|
||||||
|
m_createImportVideoThread->requestInterruption();
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,6 @@ struct CreateWallpaperData {
|
|||||||
int framerate = 0;
|
int framerate = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Create : public QObject {
|
class Create : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -90,11 +88,12 @@ public slots:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
CreateImportVideo* m_createImportVideo;
|
CreateImportVideo* m_createImportVideo;
|
||||||
Settings* m_settings;
|
Settings* m_settings;
|
||||||
|
QThread* m_createImportVideoThread;
|
||||||
QMLUtilities* m_utils;
|
QMLUtilities* m_utils;
|
||||||
CreateWallpaperData m_createWallpaperData;
|
CreateWallpaperData m_createWallpaperData;
|
||||||
QString m_workingDir;
|
QString m_workingDir;
|
||||||
float m_progress = 0.0f;
|
float m_progress = 0.0f;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#include "createimportvideo.h"
|
#include "createimportvideo.h"
|
||||||
|
|
||||||
|
CreateImportVideo::CreateImportVideo(QObject* parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CreateImportVideo::CreateImportVideo(QString videoPath, QString exportPath, QObject* parent)
|
CreateImportVideo::CreateImportVideo(QString videoPath, QString exportPath, QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
@ -140,7 +145,7 @@ bool CreateImportVideo::createWallpaperVideoPreview()
|
|||||||
#endif
|
#endif
|
||||||
emit createWallpaperStateChanged(CreateImportVideo::State::ConvertingPreviewVideo);
|
emit createWallpaperStateChanged(CreateImportVideo::State::ConvertingPreviewVideo);
|
||||||
|
|
||||||
//connect(this, &Create::abortCreateWallpaper, proConvertPreviewWebM.data(), &QProcess::kill);
|
|
||||||
proConvertPreviewWebM.data()->start();
|
proConvertPreviewWebM.data()->start();
|
||||||
while (!proConvertPreviewWebM.data()->waitForFinished(100)) //Wake up every 100ms and check if we must exit
|
while (!proConvertPreviewWebM.data()->waitForFinished(100)) //Wake up every 100ms and check if we must exit
|
||||||
{
|
{
|
||||||
@ -154,7 +159,7 @@ bool CreateImportVideo::createWallpaperVideoPreview()
|
|||||||
}
|
}
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
//disconnect(this, &Create::abortCreateWallpaper, proConvertPreviewWebM.data(), &QProcess::kill);
|
|
||||||
QString tmpErr = proConvertPreviewWebM.data()->readAllStandardError();
|
QString tmpErr = proConvertPreviewWebM.data()->readAllStandardError();
|
||||||
if (!tmpErr.isEmpty()) {
|
if (!tmpErr.isEmpty()) {
|
||||||
QFile previewVideo(m_exportPath + "/preview.webm");
|
QFile previewVideo(m_exportPath + "/preview.webm");
|
||||||
@ -195,7 +200,7 @@ bool CreateImportVideo::createWallpaperGifPreview()
|
|||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
proConvertGif.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg");
|
proConvertGif.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg");
|
||||||
#endif
|
#endif
|
||||||
//connect(this, &Create::abortCreateWallpaper, proConvertGif.data(), &QProcess::kill);
|
|
||||||
proConvertGif.data()->start();
|
proConvertGif.data()->start();
|
||||||
while (!proConvertGif.data()->waitForFinished(100)) //Wake up every 100ms and check if we must exit
|
while (!proConvertGif.data()->waitForFinished(100)) //Wake up every 100ms and check if we must exit
|
||||||
{
|
{
|
||||||
@ -209,7 +214,7 @@ bool CreateImportVideo::createWallpaperGifPreview()
|
|||||||
}
|
}
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
//disconnect(this, &Create::abortCreateWallpaper, proConvertGif.data(), &QProcess::kill);
|
|
||||||
QString tmpErrGif = proConvertGif.data()->readAllStandardError();
|
QString tmpErrGif = proConvertGif.data()->readAllStandardError();
|
||||||
if (!tmpErrGif.isEmpty()) {
|
if (!tmpErrGif.isEmpty()) {
|
||||||
QFile previewGif(m_exportPath + "/preview.gif");
|
QFile previewGif(m_exportPath + "/preview.gif");
|
||||||
@ -311,7 +316,6 @@ bool CreateImportVideo::extractWallpaperAudio()
|
|||||||
pro.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg");
|
pro.data()->setProgram(QApplication::applicationDirPath() + "/ffmpeg");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//connect(this, &Create::abortCreateWallpaper, proConvertAudio.data(), &QProcess::kill);
|
|
||||||
proConvertAudio.data()->start(QIODevice::ReadOnly);
|
proConvertAudio.data()->start(QIODevice::ReadOnly);
|
||||||
while (!proConvertAudio.data()->waitForFinished(100)) //Wake up every 100ms and check if we must exit
|
while (!proConvertAudio.data()->waitForFinished(100)) //Wake up every 100ms and check if we must exit
|
||||||
{
|
{
|
||||||
@ -325,7 +329,6 @@ bool CreateImportVideo::extractWallpaperAudio()
|
|||||||
}
|
}
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
//disconnect(this, &Create::abortCreateWallpaper, proConvertAudio.data(), &QProcess::kill);
|
|
||||||
|
|
||||||
QString tmpErrImg = proConvertAudio.data()->readAllStandardError();
|
QString tmpErrImg = proConvertAudio.data()->readAllStandardError();
|
||||||
if (!tmpErrImg.isEmpty()) {
|
if (!tmpErrImg.isEmpty()) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -8,16 +10,15 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QThread>
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QApplication>
|
#include <QString>
|
||||||
|
#include <QThread>
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
class CreateImportVideo : public QObject {
|
class CreateImportVideo : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
CreateImportVideo(QObject* parent = nullptr);
|
||||||
explicit CreateImportVideo(QString videoPath, QString exportPath, QObject* parent = nullptr);
|
explicit CreateImportVideo(QString videoPath, QString exportPath, QObject* parent = nullptr);
|
||||||
|
|
||||||
enum class State {
|
enum class State {
|
||||||
@ -58,7 +59,6 @@ public slots:
|
|||||||
void process();
|
void process();
|
||||||
void requestInterruption()
|
void requestInterruption()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool createWallpaperInfo();
|
bool createWallpaperInfo();
|
||||||
|
Loading…
Reference in New Issue
Block a user