1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-10-06 09:17:07 +02:00

Add help for choosing codec

This commit is contained in:
Elias 2020-02-06 10:49:11 +01:00
parent 7a9769f2d9
commit 5ae555da32
10 changed files with 182 additions and 51 deletions

View File

@ -144,5 +144,6 @@
<file>assets/wizards/example_qml.png</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaperCodec.qml</file>
<file>qml/Create/Wizards/CreateWallpaper/CreateWallpaper.qml</file>
<file>qml/Common/Headline.qml</file>
</qresource>
</RCC>

View File

@ -0,0 +1,29 @@
import QtQuick 2.14
Item {
id:root
width: parent.width
height: 40
property alias text: txtHeadline
Text {
id: txtHeadline
font.family: "Roboto"
font.pointSize: 18
color: "#444444"
text: qsTr("Headline")
}
Rectangle {
height: 2
width: parent.width
color: "#444444"
anchors {
right:parent.right
left:parent.left
bottom: parent.bottom
}
}
}

View File

@ -27,8 +27,11 @@ Item {
swipeView.currentIndex = 1
ScreenPlay.create.createWallpaperStart(filePath,codec)
}
onCodecChanged:createWallpaperVideoImportConvert.codec = codec
}
CreateWallpaperVideoImportConvert {
id:createWallpaperVideoImportConvert
}
CreateWallpaperVideoImportConvert {}
CreateWallpaperResult {}
}

View File

@ -4,6 +4,7 @@ import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.3
import Qt.labs.platform 1.0
import QtQuick.Layouts 1.12
import QtWebEngine 1.8
import ScreenPlay 1.0
import ScreenPlay.Create 1.0
@ -13,40 +14,112 @@ import "../../../Common"
Item {
id: root
property var codec: Create.All
onCodecChanged: print(codec)
property var codec: Create.VP8
signal next
Timer {
running: true
interval: 1000
onTriggered: webView.url = "https://kelteseth.gitlab.io/ScreenPlayDocs/wallpaper/wallpaper/#performance"
}
ComboBox {
id: comboBoxCodec
textRole: "text"
valueRole: "value"
anchors.centerIn: parent
onCurrentIndexChanged: {
root.codec = model.get(comboBoxCodec.currentIndex).value
}
model: ListModel {
id: model
ListElement {
text: "Both"
value: Create.All
}
ListElement {
text: "VP8"
value: Create.VP8
}
ListElement {
text: "VP9"
value: Create.VP9
}
WebEngineView {
id: webView
backgroundColor: "gray"
width: parent.width * .66
anchors {
margins: 20
top: parent.top
left: parent.left
bottom: parent.bottom
}
}
Column {
spacing: 10
anchors {
top: parent.top
left: webView.right
bottom: parent.bottom
right: parent.right
margins: 40
}
Headline {
Layout.alignment: Qt.AlignTop
text.text: qsTr("Import a video")
}
Item {
width: parent.width
height: 5
}
Text {
id: txtDescription
text: qsTr("Depending on your PC configuration it is better to convert your wallpaper to a specific video codec. If both have bad performance you can also try a QML wallpaper!")
color: "gray"
width: parent.width
font.pointSize: 13
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
}
Item {
width: parent.width
height: 50
}
Text {
id: txtComboboxHeadline
text: qsTr("Set your preffered video codec:")
color: "gray"
width: parent.width
font.pointSize: 14
}
ComboBox {
id: comboBoxCodec
textRole: "text"
width: 300
valueRole: "value"
onCurrentIndexChanged: {
root.codec = model.get(comboBoxCodec.currentIndex).value
}
model: ListModel {
id: model
ListElement {
text: "VP8 (Old Intel best)"
value: Create.VP8
}
ListElement {
text: "VP9 (AMD/Nvidia best)"
value: Create.VP9
}
}
}
}
Button {
text: qsTr("Open Documentation")
Material.background: Material.LightGreen
Material.foreground: "white"
icon.source: "qrc:/assets/icons/icon_document.svg"
icon.color: "white"
icon.width: 16
icon.height: 16
onClicked: Qt.openUrlExternally(
"https://kelteseth.gitlab.io/ScreenPlayDocs/wallpaper/wallpaper/#performance")
anchors {
left: webView.right
bottom: parent.bottom
margins: 20
}
}
Button {
text: qsTr("Next")
highlighted: true
onClicked: {
root.next()
}
@ -54,6 +127,7 @@ Item {
anchors {
right: parent.right
bottom: parent.bottom
margins: 20
}
}
}

View File

@ -15,6 +15,7 @@ Item {
property bool conversionFinishedSuccessful: false
property bool canSave: false
property var codec: Create.VP8
property string filePath
@ -84,6 +85,9 @@ Item {
case CreateImportVideo.ConvertingVideoError:
txtConvert.text = qsTr("Converting Video ERROR!")
break
case CreateImportVideo.AnalyseVideoError:
txtConvert.text = qsTr("Analyse Video ERROR!")
break
case CreateImportVideo.Finished:
txtConvert.text = ""
conversionFinishedSuccessful = true
@ -318,6 +322,7 @@ Item {
wrapperContent.filePath,
previewSelector.imageSource,
textFieldYoutubeURL.text,
codec,
textFieldTags.getTags())
savePopup.open()
ScreenPlay.installedListModel.reset()

View File

@ -148,9 +148,15 @@ void Create::createWallpaperStart(QString videoPath, Create::VideoCodec codec)
return;
}
setWorkingDir(dir.path() + "/" + folderName);
QStringList codecs;
if (codec == Create::VideoCodec::VP8) {
codecs.append("vp8");
} else {
codecs.append("vp9");
}
m_createImportVideoThread = new QThread();
m_createImportVideo = new CreateImportVideo(videoPath, workingDir());
m_createImportVideo = new CreateImportVideo(videoPath, workingDir(), codecs);
connect(m_createImportVideo, &CreateImportVideo::processOutput, this, [this](QString text) {
appendFfmpegOutput(text + "\n");
});
@ -171,7 +177,7 @@ void Create::createWallpaperStart(QString videoPath, Create::VideoCodec codec)
/*!
When converting of the wallpaper steps where successful.
*/
void Create::saveWallpaper(QString title, QString description, QString filePath, QString previewImagePath, QString youtube, QVector<QString> tags)
void Create::saveWallpaper(QString title, QString description, QString filePath, QString previewImagePath, QString youtube, Create::VideoCodec codec, QVector<QString> tags)
{
filePath.remove("file:///");
previewImagePath.remove("file:///");
@ -214,7 +220,11 @@ void Create::saveWallpaper(QString title, QString description, QString filePath,
obj.insert("description", description);
obj.insert("title", title);
obj.insert("youtube", youtube);
obj.insert("videoCodec", "vp8");
if (codec == Create::VideoCodec::VP8) {
obj.insert("videoCodec", "vp8");
} else {
obj.insert("videoCodec", "vp9");
}
QFile audioFile { m_workingDir + "/audio.mp3" };
if (audioFile.exists() && audioFile.size() > 0) {

View File

@ -45,7 +45,6 @@ public:
Create();
enum class VideoCodec {
All,
VP8,
VP9
};
@ -85,7 +84,7 @@ public slots:
const QVector<QString>& tags);
void createWallpaperStart(QString videoPath, Create::VideoCodec codec);
void saveWallpaper(QString title, QString description, QString filePath, QString previewImagePath, QString youtube, QVector<QString> tags);
void saveWallpaper(QString title, QString description, QString filePath, QString previewImagePath, QString youtube, ScreenPlay::Create::VideoCodec codec, QVector<QString> tags);
void abortAndCleanup();
void setProgress(float progress)

View File

@ -28,11 +28,12 @@ CreateImportVideo::CreateImportVideo(QObject* parent)
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, QObject* parent)
CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& exportPath, const QStringList& codecs, QObject* parent)
: QObject(parent)
{
m_videoPath = videoPath;
m_exportPath = exportPath;
m_codecs = codecs;
#ifdef Q_OS_WIN
m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe.exe";
@ -47,7 +48,6 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex
#if defined(Q_OS_MACOS) || defined(Q_OS_UNIX)
m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg";
#endif
}
/*!
@ -90,9 +90,11 @@ void CreateImportVideo::process()
return;
}
if (!createWallpaperVideo() || QThread::currentThread()->isInterruptionRequested()) {
emit abortAndCleanup();
return;
for (const auto codec : m_codecs) {
if (!createWallpaperVideo(codec) || QThread::currentThread()->isInterruptionRequested()) {
emit abortAndCleanup();
return;
}
}
// If the video has no audio we can skip the extraction
@ -499,12 +501,12 @@ bool CreateImportVideo::createWallpaperImagePreview()
\li Generally broken.
\endlist
*/
bool CreateImportVideo::createWallpaperVideo()
bool CreateImportVideo::createWallpaperVideo(const QString& codec)
{
if (m_videoPath.endsWith(".webm")) {
return true;
}
// if (m_videoPath.endsWith(".webm")) {
// return true;
// }
emit createWallpaperStateChanged(ImportVideoState::ConvertingVideo);
@ -515,7 +517,12 @@ bool CreateImportVideo::createWallpaperVideo()
args.append("-i");
args.append(m_videoPath);
args.append("-c:v");
args.append("libvpx");
if (codec == "vp8") {
args.append("libvpx");
}
if (codec == "vp9") {
args.append("libvpx-vp9");
}
args.append("-b:v");
args.append("0");
args.append("-crf");
@ -523,16 +530,15 @@ bool CreateImportVideo::createWallpaperVideo()
args.append("-pass");
args.append("1");
#ifdef Q_OS_WIN
args.append("-an");
args.append("-f");
args.append("webm");
#ifdef Q_OS_WIN
args.append("NULL");
#endif
#ifdef Q_OS_MACOS
args.append("-an");
args.append("-f");
args.append("webm");
args.append("/dev/null");
#endif
@ -541,7 +547,6 @@ bool CreateImportVideo::createWallpaperVideo()
proConvertVideoPass1->setProgram(m_ffmpegExecutable);
proConvertVideoPass1->setProcessChannelMode(QProcess::MergedChannels);
connect(proConvertVideoPass1.get(), &QProcess::readyReadStandardOutput, this, [&]() {
QString tmpOut = proConvertVideoPass1->readAllStandardOutput();
if (tmpOut.contains("Conversion failed!")) {
@ -567,7 +572,6 @@ bool CreateImportVideo::createWallpaperVideo()
waitForFinished(proConvertVideoPass1);
proConvertVideoPass1->close();
args.clear();
args.append("-hide_banner");
args.append("-y");
@ -575,7 +579,12 @@ bool CreateImportVideo::createWallpaperVideo()
args.append("-i");
args.append(m_videoPath);
args.append("-c:v");
args.append("libvpx");
if (codec == "vp8") {
args.append("libvpx");
}
if (codec == "vp9") {
args.append("libvpx-vp9");
}
args.append("-b:v");
args.append("0");
args.append("-crf");

View File

@ -31,7 +31,7 @@ public:
qDebug() << "CreateImportVideo";
}
CreateImportVideo(QObject* parent = nullptr);
explicit CreateImportVideo(const QString& videoPath, const QString& exportPath, QObject* parent = nullptr);
explicit CreateImportVideo(const QString& videoPath, const QString& exportPath, const QStringList& codecs, QObject* parent = nullptr);
bool m_skipAudio { false };
@ -40,6 +40,7 @@ public:
QString m_videoPath;
QString m_exportPath;
QString m_format;
QStringList m_codecs;
int m_numberOfFrames { 0 };
int m_length { 0 };
@ -101,7 +102,7 @@ public slots:
bool createWallpaperVideoPreview();
bool createWallpaperGifPreview();
bool createWallpaperImagePreview();
bool createWallpaperVideo();
bool createWallpaperVideo(const QString &codec);
bool extractWallpaperAudio();
bool createWallpaperImageThumbnailPreview();

View File

@ -298,7 +298,7 @@ void Util::Util::requestDataProtection()
void Util::downloadFFMPEG()
{
QNetworkRequest req;
QString ffmpegVersion { "ffmpeg-4.2.1" };
QString ffmpegVersion { "ffmpeg-4.2.2" };
#ifdef Q_OS_WIN
req.setUrl(QUrl("https://ffmpeg.zeranoe.com/builds/win64/static/" + ffmpegVersion + "-win64-static.zip"));