Add handbrake encode progress to UI.
Add encode stop button. Movie now searches when selected. First result in UI.
This commit is contained in:
parent
d339ced03b
commit
28ab770b3e
48
Main.qml
48
Main.qml
@ -56,11 +56,20 @@ Window {
|
||||
wrapMode: TextEdit.Wrap
|
||||
}
|
||||
|
||||
Text {
|
||||
id: searchResult
|
||||
anchors.left: btnVideoFile.left
|
||||
anchors.top: hdrType.bottom
|
||||
width: 200
|
||||
text: "No Results"
|
||||
wrapMode: TextEdit.Wrap
|
||||
}
|
||||
|
||||
Button {
|
||||
id: btnStartEncode
|
||||
anchors.topMargin: 25
|
||||
anchors.leftMargin: 25
|
||||
anchors.top: hdrType.bottom
|
||||
anchors.top: searchResult.bottom
|
||||
anchors.left: parent.left
|
||||
text: "Start Encode"
|
||||
font.pixelSize: 14
|
||||
@ -70,7 +79,28 @@ Window {
|
||||
width: 100
|
||||
}
|
||||
|
||||
Button {
|
||||
id: btnStopEncode
|
||||
anchors.topMargin: 25
|
||||
anchors.leftMargin: 25
|
||||
anchors.top: searchResult.bottom
|
||||
anchors.left: btnStartEncode.right
|
||||
text: "Stop Encode"
|
||||
font.pixelSize: 14
|
||||
onClicked: handbrake.stopEncode()
|
||||
flat: false
|
||||
height: font.pixelSize + 10
|
||||
width: 100
|
||||
}
|
||||
|
||||
Text {
|
||||
id: handbrakeStatus
|
||||
anchors.left: btnVideoFile.left
|
||||
anchors.bottom: parent.bottom
|
||||
width: 600
|
||||
text: "Encode not started."
|
||||
wrapMode: TextEdit.Wrap
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: videoFileDialog
|
||||
@ -94,6 +124,22 @@ Window {
|
||||
default:
|
||||
hdrType.text = "Error"
|
||||
}
|
||||
|
||||
movieDB.searchMovieTitleFile(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: movieDB
|
||||
function onSearchResultReturned(result) {
|
||||
searchResult.text = "First Result: " + result;
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: handbrake
|
||||
function onStatusChanged(status) {
|
||||
handbrakeStatus.text = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include "QHandbrake.h"
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
|
||||
QHandbrake::QHandbrake(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
|
||||
: QObject{parent} {
|
||||
}
|
||||
|
||||
uint8_t QHandbrake::setPath(QString pathIn)
|
||||
@ -23,8 +22,24 @@ uint8_t QHandbrake::startEncode()
|
||||
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);
|
||||
HBProcess = new QProcess(parent());
|
||||
HBProcess->start(exePath, arguments);
|
||||
|
||||
emit statusChanged("Encode started.");
|
||||
|
||||
QObject::connect(HBProcess, &QProcess::readyReadStandardOutput, this, &QHandbrake::printStandardStatus);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t QHandbrake::stopEncode() {
|
||||
QObject::disconnect(HBProcess, &QProcess::readyReadStandardOutput, this, &QHandbrake::printStandardStatus);
|
||||
HBProcess->close();
|
||||
emit statusChanged("Encode stopped.");
|
||||
return true;
|
||||
}
|
||||
|
||||
void QHandbrake::printStandardStatus() {
|
||||
emit statusChanged(HBProcess->readAllStandardOutput().trimmed());
|
||||
//qInfo() << HBProcess->readAllStandardOutput().trimmed();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define QHANDBRAKE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
|
||||
class QHandbrake : public QObject
|
||||
{
|
||||
@ -11,12 +12,15 @@ public:
|
||||
explicit QHandbrake(QObject *parent = nullptr);
|
||||
uint8_t setPath(QString pathIn);
|
||||
Q_INVOKABLE uint8_t startEncode();
|
||||
Q_INVOKABLE uint8_t stopEncode();
|
||||
|
||||
private:
|
||||
QString exePath = "";
|
||||
QProcess *HBProcess;
|
||||
void printStandardStatus();
|
||||
|
||||
signals:
|
||||
|
||||
void statusChanged(QString status);
|
||||
};
|
||||
|
||||
#endif // QHANDBRAKE_H
|
||||
|
20
main.cpp
20
main.cpp
@ -26,7 +26,7 @@ int main(int argc, char *argv[])
|
||||
QMovieDB movieDB(settings.value("MovieDB API Key").toString());
|
||||
|
||||
//movieDB.searchMovieTitle("10 cloverfield lane"); //Single Result Example
|
||||
movieDB.searchMovieTitle("The Shawshank Redemption"); //Multi-result
|
||||
//movieDB.searchMovieTitle("The Shawshank Redemption"); //Multi-result
|
||||
|
||||
// //Check if HDR/DolbyVision
|
||||
// enum QMediaInfo::HDR_Type hdrType = mInfo.getHDRType(__T("Cosmos.mkv"));
|
||||
@ -37,21 +37,25 @@ int main(int argc, char *argv[])
|
||||
// }
|
||||
|
||||
QHandbrake handbrake;
|
||||
if (handbrake.setPath("J:\\Video\\VideoTools\\HandBrakeCLI.exe") ==1 ) {
|
||||
qInfo() << "Success";
|
||||
//handbrake.startEncode();
|
||||
#ifdef linux
|
||||
if (handbrake.setPath("/usr/bin/HandBrakeCLI")) {
|
||||
qInfo() << "Handbrake executable set";
|
||||
} else {
|
||||
qWarning() << "Handbrake executable not found.";
|
||||
}
|
||||
else if (handbrake.setPath("/usr/bin/HandBrakeCLI")) {
|
||||
qInfo() << "Succes Linux";
|
||||
#else
|
||||
if (handbrake.setPath(settings.value("HandbrakeExe_Path").toString())) {
|
||||
qInfo() << "Handbrake executable set";
|
||||
}
|
||||
else {
|
||||
qInfo() << "fail";
|
||||
qWarning() << "Handbrake executable not found.";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextProperty("mediaInfo", &mInfo);
|
||||
engine.rootContext()->setContextProperty("handbrake", &handbrake);
|
||||
engine.rootContext()->setContextProperty("movieDB", &movieDB);
|
||||
|
||||
const QUrl url(u"qrc:/DoViGUI/Main.qml"_qs);
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
|
15
qmoviedb.cpp
15
qmoviedb.cpp
@ -26,6 +26,14 @@ void QMovieDB::searchMovieTitle(const QString title)
|
||||
netMan->get(req);
|
||||
}
|
||||
|
||||
|
||||
//Remove path and extension of filename before searching
|
||||
void QMovieDB::searchMovieTitleFile(const QString file) {
|
||||
uint8_t endURI = file.lastIndexOf('/');
|
||||
uint8_t startExt = file.lastIndexOf('.');
|
||||
searchMovieTitle(file.sliced(endURI + 1, startExt - endURI - 1));
|
||||
}
|
||||
|
||||
void QMovieDB::receiveReply(QNetworkReply *reply) {
|
||||
int responseStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
|
||||
@ -47,7 +55,10 @@ void QMovieDB::parseResults(QJsonObject json) {
|
||||
QString titleYear = results.at(i).toObject().value("title").toString() + " " + releaseYear;
|
||||
|
||||
qInfo() << "Result " << (i + 1) << ": " << titleYear;
|
||||
}
|
||||
|
||||
|
||||
//For now only returning first result
|
||||
if (i == 0) {
|
||||
emit searchResultReturned(titleYear);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ public:
|
||||
QNetworkAccessManager *netMan;
|
||||
|
||||
void searchMovieTitle(const QString title);
|
||||
Q_INVOKABLE void searchMovieTitleFile(const QString file);
|
||||
|
||||
private:
|
||||
QString movieDbApiKey;
|
||||
@ -23,6 +24,7 @@ private slots:
|
||||
void parseResults(QJsonObject json);
|
||||
|
||||
signals:
|
||||
void searchResultReturned(QString fullTitle);
|
||||
};
|
||||
|
||||
#endif // QMOVIEDB_H
|
||||
|
Loading…
Reference in New Issue
Block a user