-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a video quality measurement job to the encode job results.
- Loading branch information
Showing
6 changed files
with
218 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright (c) 2012-2015 Meltytech, LLC | ||
* Author: Dan Dennedy <dan@dennedy.org> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "videoqualityjob.h" | ||
#include <QAction> | ||
#include <QFile> | ||
#include <QDomDocument> | ||
#include <QTextStream> | ||
#include <QFileInfo> | ||
#include <QUrl> | ||
#include <QDesktopServices> | ||
#include "mainwindow.h" | ||
#include "dialogs/textviewerdialog.h" | ||
|
||
VideoQualityJob::VideoQualityJob(const QString& name, const QString& xmlPath, | ||
const QString& reportPath) | ||
: MeltJob(name, xmlPath) | ||
, m_reportPath(reportPath) | ||
{ | ||
QAction* action = new QAction(tr("Open"), this); | ||
action->setToolTip(tr("Open original and encoded side-by-side in the Shotcut player")); | ||
connect(action, &QAction::triggered, this, &VideoQualityJob::onOpenTiggered); | ||
m_successActions << action; | ||
|
||
action = new QAction(tr("View Report"), this); | ||
connect(action, &QAction::triggered, this, &VideoQualityJob::onViewReportTriggered); | ||
m_successActions << action; | ||
|
||
action = new QAction(tr("Show In Folder"), this); | ||
connect(action, &QAction::triggered, this, &VideoQualityJob::onShowFolderTriggered); | ||
m_successActions << action; | ||
|
||
setLabel(tr("Measure %1").arg(objectName())); | ||
setStandardOutputFile(reportPath); | ||
} | ||
|
||
void VideoQualityJob::onOpenTiggered() | ||
{ | ||
// Parse the XML. | ||
QFile file(xmlPath()); | ||
file.open(QIODevice::ReadOnly); | ||
QDomDocument dom(xmlPath()); | ||
dom.setContent(&file); | ||
file.close(); | ||
|
||
// Locate the VQM transition. | ||
QDomNodeList transitions = dom.elementsByTagName("transition"); | ||
for (int i = 0; i < transitions.length(); i++ ) { | ||
QDomElement property = transitions.at(i).firstChildElement("property"); | ||
while (!property.isNull()) { | ||
// Change the render property to 1. | ||
if (property.attribute("name") == "render") { | ||
property.firstChild().setNodeValue("1"); | ||
|
||
// Save the new XML. | ||
file.open(QIODevice::WriteOnly); | ||
QTextStream textStream(&file); | ||
dom.save(textStream, 2); | ||
file.close(); | ||
|
||
MAIN.open(xmlPath().toUtf8().constData()); | ||
break; | ||
} | ||
property = property.nextSiblingElement("property"); | ||
} | ||
} | ||
} | ||
|
||
void VideoQualityJob::onViewReportTriggered() | ||
{ | ||
TextViewerDialog dialog(&MAIN); | ||
dialog.setWindowTitle(tr("Video Quality Measurement")); | ||
QFile f(m_reportPath); | ||
f.open(QIODevice::ReadOnly); | ||
QString s(f.readAll()); | ||
f.close(); | ||
dialog.setText(s); | ||
dialog.exec(); | ||
} | ||
|
||
void VideoQualityJob::onShowFolderTriggered() | ||
{ | ||
QFileInfo fi(m_reportPath); | ||
QUrl url(QString("file://").append(fi.path()), QUrl::TolerantMode); | ||
QDesktopServices::openUrl(url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2012-2015 Meltytech, LLC | ||
* Author: Dan Dennedy <dan@dennedy.org> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef VIDEOQUALITYJOB_H | ||
#define VIDEOQUALITYJOB_H | ||
|
||
#include "meltjob.h" | ||
|
||
class VideoQualityJob : public MeltJob | ||
{ | ||
public: | ||
VideoQualityJob(const QString& name, const QString& xmlPath, | ||
const QString& reportPath); | ||
|
||
private slots: | ||
void onOpenTiggered(); | ||
void onViewReportTriggered(); | ||
void onShowFolderTriggered(); | ||
|
||
private: | ||
QString m_reportPath; | ||
}; | ||
|
||
#endif // VIDEOQUALITYJOB_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters