From 081e541b5c5aae6a41fdae96a5e70ad703dae1a2 Mon Sep 17 00:00:00 2001 From: bissen21 Date: Sun, 29 Oct 2023 13:42:40 -0500 Subject: [PATCH] Rename mediaInfo. Start work on handbrake process --- DoViGUI/CMakeLists.txt | 3 ++- DoViGUI/Main.qml | 14 ++++++++++ DoViGUI/QHandbrake.cpp | 30 +++++++++++++++++++++ DoViGUI/QHandbrake.h | 22 +++++++++++++++ DoViGUI/{myMediaInfo.cpp => QMediaInfo.cpp} | 9 +++---- DoViGUI/{myMediaInfo.h => QMediaInfo.h} | 10 +++---- DoViGUI/main.cpp | 27 +++++++++++++------ 7 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 DoViGUI/QHandbrake.cpp create mode 100644 DoViGUI/QHandbrake.h rename DoViGUI/{myMediaInfo.cpp => QMediaInfo.cpp} (67%) rename DoViGUI/{myMediaInfo.h => QMediaInfo.h} (63%) diff --git a/DoViGUI/CMakeLists.txt b/DoViGUI/CMakeLists.txt index 5c15e8c..da5c044 100644 --- a/DoViGUI/CMakeLists.txt +++ b/DoViGUI/CMakeLists.txt @@ -17,8 +17,9 @@ qt_add_qml_module(appDoViGUI VERSION 1.0 QML_FILES Main.qml SOURCES MediaInfoDLL.h - SOURCES myMediaInfo.h myMediaInfo.cpp + SOURCES QMediaInfo.h QMediaInfo.cpp RESOURCES MediaInfo.dll + SOURCES QHandbrake.h QHandbrake.cpp ) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. diff --git a/DoViGUI/Main.qml b/DoViGUI/Main.qml index a6a6af4..84d5ea5 100644 --- a/DoViGUI/Main.qml +++ b/DoViGUI/Main.qml @@ -56,6 +56,20 @@ Window { wrapMode: TextEdit.Wrap } + Button { + id: btnStartEncode + anchors.topMargin: 25 + anchors.leftMargin: 25 + anchors.top: hdrType.bottom + anchors.left: parent.left + text: "Start Encode" + font.pixelSize: 14 + onClicked: handbrake.startEncode() + flat: false + height: font.pixelSize + 10 + width: 100 + } + FileDialog { diff --git a/DoViGUI/QHandbrake.cpp b/DoViGUI/QHandbrake.cpp new file mode 100644 index 0000000..03c08da --- /dev/null +++ b/DoViGUI/QHandbrake.cpp @@ -0,0 +1,30 @@ +#include "QHandbrake.h" +#include +#include + +QHandbrake::QHandbrake(QObject *parent) + : QObject{parent} +{ + +} + +uint8_t QHandbrake::setPath(QString pathIn) +{ + if (QFile::exists(pathIn)) { + exePath = pathIn; + return 1; + } + return -1; +} + +uint8_t QHandbrake::startEncode() +{ + //HandBrakeCLI -i "../%TITLE%/%TITLE% - 4k.mkv" -o "../%TITLE%/temp/handbrake.mkv" -f av_mkv -m -e x265_10bit --encoder-preset slower -q 20 --encoder-profile auto --all-audio -E copy --audio-copy-mask aac,eac3,dts,ac3,truehd,dtshd,mp3 --crop-mode auto --auto-anamorphic --all-subtitles > "../%TITLE%/temp/log.txt" + QStringList arguments; + arguments << "-i" << "Cosmos.mkv" << "-o" << "test.mkv" << "-f" << "av_mkv" << "-m" << "-e" << "x265_10bit" << "--encoder-preset" << "slower" << "-q" << "20" << "--encoder-profile" << "auto" << "--all-audio" << "-E" << "copy" << "--audio-copy-mask" << "aac,eac3,dts,ac3,truehd,dtshd,mp3" << "--crop-mode" << "auto" << "--auto-anamorphic" << "--all-subtitles"; + + QProcess *myProcess = new QProcess(parent()); + myProcess->start(exePath, arguments); + + return true; +} diff --git a/DoViGUI/QHandbrake.h b/DoViGUI/QHandbrake.h new file mode 100644 index 0000000..4df34bc --- /dev/null +++ b/DoViGUI/QHandbrake.h @@ -0,0 +1,22 @@ +#ifndef QHANDBRAKE_H +#define QHANDBRAKE_H + +#include + +class QHandbrake : public QObject +{ + Q_OBJECT + +public: + explicit QHandbrake(QObject *parent = nullptr); + uint8_t setPath(QString pathIn); + Q_INVOKABLE uint8_t startEncode(); + +private: + QString exePath = ""; + +signals: + +}; + +#endif // QHANDBRAKE_H diff --git a/DoViGUI/myMediaInfo.cpp b/DoViGUI/QMediaInfo.cpp similarity index 67% rename from DoViGUI/myMediaInfo.cpp rename to DoViGUI/QMediaInfo.cpp index 8fb236e..dffca33 100644 --- a/DoViGUI/myMediaInfo.cpp +++ b/DoViGUI/QMediaInfo.cpp @@ -1,14 +1,13 @@ -#include "myMediaInfo.h" +#include "QMediaInfo.h" #include "MediaInfoDLL.h" -#include "qvariant.h" #include -myMediaInfo::myMediaInfo(QObject *parent){} +QMediaInfo::QMediaInfo(QObject *parent){} -enum myMediaInfo::HDR_Type myMediaInfo::getHDRType(const MediaInfoDLL::String fileName) { +enum QMediaInfo::HDR_Type QMediaInfo::getHDRType(const MediaInfoDLL::String fileName) { if (Open(fileName)) { MediaInfoDLL::String HDRtext = Get(MediaInfoDLL::Stream_Video, 0, __T("HDR_Format"), MediaInfoDLL::Info_Text, MediaInfoDLL::Info_Name); Close(); @@ -24,6 +23,6 @@ enum myMediaInfo::HDR_Type myMediaInfo::getHDRType(const MediaInfoDLL::String fi return ERR; } -enum myMediaInfo::HDR_Type myMediaInfo::getHDRType(const QString fileName) { +enum QMediaInfo::HDR_Type QMediaInfo::getHDRType(const QString fileName) { return getHDRType(fileName.toStdWString()); } diff --git a/DoViGUI/myMediaInfo.h b/DoViGUI/QMediaInfo.h similarity index 63% rename from DoViGUI/myMediaInfo.h rename to DoViGUI/QMediaInfo.h index 966ea89..bf3f18f 100644 --- a/DoViGUI/myMediaInfo.h +++ b/DoViGUI/QMediaInfo.h @@ -1,15 +1,15 @@ -#ifndef MYMEDIAINFO_H -#define MYMEDIAINFO_H +#ifndef QMEDIAINFO_H +#define QMEDIAINFO_H #include //#include "qvariant.h" #include -class myMediaInfo : public QObject, public MediaInfoDLL::MediaInfo { +class QMediaInfo : public QObject, public MediaInfoDLL::MediaInfo { Q_OBJECT public: - myMediaInfo(QObject* parent = nullptr); + QMediaInfo(QObject* parent = nullptr); enum HDR_Type{ERR = -1, SDR = 0, HDR = 1, DOVI = 2}; Q_ENUM(HDR_Type) @@ -21,4 +21,4 @@ private: }; -#endif // MYMEDIAINFO_H +#endif // QMEDIAINFO_H diff --git a/DoViGUI/main.cpp b/DoViGUI/main.cpp index f45228c..c77bfb0 100644 --- a/DoViGUI/main.cpp +++ b/DoViGUI/main.cpp @@ -1,6 +1,7 @@ #include #include -#include +#include +#include #include #include @@ -10,19 +11,29 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - myMediaInfo mInfo(&app); + QMediaInfo mInfo(&app); - //Check if HDR/DolbyVision - enum myMediaInfo::HDR_Type hdrType = mInfo.getHDRType(__T("Cosmos.mkv")); - if (hdrType >= 0) { - qInfo() << hdrType; - } else { - qWarning() << "Could not open file."; +// //Check if HDR/DolbyVision +// enum QMediaInfo::HDR_Type hdrType = mInfo.getHDRType(__T("Cosmos.mkv")); +// if (hdrType >= 0) { +// qInfo() << hdrType; +// } else { +// qWarning() << "Could not open file."; +// } + + QHandbrake handbrake; + if (handbrake.setPath("J:\\Video\\VideoTools\\HandBrakeCLI.exe") ==1 ) { + qInfo() << "Success"; + //handbrake.startEncode(); + } + else { + qInfo() << "fail"; } QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("mediaInfo", &mInfo); + engine.rootContext()->setContextProperty("handbrake", &handbrake); const QUrl url(u"qrc:/DoViGUI/Main.qml"_qs); QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,