Rename mediaInfo. Start work on handbrake process

This commit is contained in:
Adam Bissen 2023-10-29 13:42:40 -05:00
parent eeaec187cb
commit 081e541b5c
7 changed files with 96 additions and 19 deletions

View File

@ -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.

View File

@ -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 {

30
DoViGUI/QHandbrake.cpp Normal file
View File

@ -0,0 +1,30 @@
#include "QHandbrake.h"
#include <QFile>
#include <QProcess>
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;
}

22
DoViGUI/QHandbrake.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef QHANDBRAKE_H
#define QHANDBRAKE_H
#include <QObject>
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

View File

@ -1,14 +1,13 @@
#include "myMediaInfo.h"
#include "QMediaInfo.h"
#include "MediaInfoDLL.h"
#include "qvariant.h"
#include <QDebug>
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());
}

View File

@ -1,15 +1,15 @@
#ifndef MYMEDIAINFO_H
#define MYMEDIAINFO_H
#ifndef QMEDIAINFO_H
#define QMEDIAINFO_H
#include <QObject>
//#include "qvariant.h"
#include <MediaInfoDLL.h>
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

View File

@ -1,6 +1,7 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <myMediaInfo.h>
#include <QMediaInfo.h>
#include <QHandbrake.h>
#include <QFile>
#include <QQmlContext>
@ -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,