summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2009-09-26 18:20:21 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2009-09-26 18:20:21 -0400
commit52c533d9f1e90322bbc57740ddfe7ebccf598fd3 (patch)
treea9b17aca105ffbf367dc10e7b5ac2e1afb75028d
parentEncoding skeleton and cleanups. (diff)
downloadAnyRip-52c533d9f1e90322bbc57740ddfe7ebccf598fd3.tar.xz
AnyRip-52c533d9f1e90322bbc57740ddfe7ebccf598fd3.zip
More HandBrake progress
-rw-r--r--AnyRip.pro6
-rw-r--r--dvdimagejobgui.cpp4
-rw-r--r--encodemp4job.cpp37
-rw-r--r--encodemp4job.h3
-rw-r--r--mainwindow.cpp12
5 files changed, 42 insertions, 20 deletions
diff --git a/AnyRip.pro b/AnyRip.pro
index 1ed10a1..787350b 100644
--- a/AnyRip.pro
+++ b/AnyRip.pro
@@ -10,7 +10,8 @@ SOURCES += main.cpp \
uploadjob.cpp \
titleloadjob.cpp \
videogui.cpp \
- mainwindow.cpp
+ mainwindow.cpp \
+ encodemp4jobgui.cpp
HEADERS += dvdimagejob.h \
dvdimagejobgui.h \
job.h \
@@ -22,7 +23,8 @@ HEADERS += dvdimagejob.h \
uploadjob.h \
titleloadjob.h \
videogui.h \
- mainwindow.h
+ mainwindow.h \
+ encodemp4jobgui.h
LIBS += -ldvdcss \
-ldvdread
QT += dbus
diff --git a/dvdimagejobgui.cpp b/dvdimagejobgui.cpp
index 5f22b80..08cb444 100644
--- a/dvdimagejobgui.cpp
+++ b/dvdimagejobgui.cpp
@@ -2,11 +2,9 @@
#include "dvdimagejob.h"
#include "dvddrive.h"
#include <dvdcss/dvdcss.h>
-#include <QPushButton>
#include <QProgressBar>
#include <QLabel>
#include <QVBoxLayout>
-#include <QFile>
DVDImageJobGui::DVDImageJobGui(DVDImageJob *job) :
m_first(true)
@@ -30,7 +28,7 @@ void DVDImageJobGui::extractProgress(int current, int maximum)
long long maximumBytes = (long long)maximum * DVDCSS_BLOCK_SIZE;
double bytesPerMillisecond = (double)currentBytes / (double)m_startTime.elapsed();
long long millisecondsRemaining = (long long)((maximumBytes - currentBytes) / bytesPerMillisecond);
- m_progressLabel->setText(QString("%1 of %2 megabytes (%3 mb/s, %4 remaining)")
+ m_progressLabel->setText(tr("%1 of %2 mb (%3 mb/s, %4 remaining)")
.arg(QString::number((double)currentBytes / 1024.0 / 1024.0, 'f', 2))
.arg(QString::number((double)maximumBytes / 1024.0 / 1024.0, 'f', 2))
.arg(QString::number(bytesPerMillisecond * (1000.0 / 1024.0 / 1024.0), 'f', 2))
diff --git a/encodemp4job.cpp b/encodemp4job.cpp
index d056002..dba84f4 100644
--- a/encodemp4job.cpp
+++ b/encodemp4job.cpp
@@ -1,10 +1,12 @@
#include "encodemp4job.h"
+#include "encodemp4jobgui.h"
#include <QWidget>
#include <QLabel>
#include <QProcess>
#include <QStringList>
#include <QTextStream>
#include <QRegExp>
+#include <QTime>
EncodeMP4Job::EncodeMP4Job(Video *video, QString encodePath, QString imagePath) :
Job(video),
@@ -24,29 +26,48 @@ bool EncodeMP4Job::executeJob()
arguments << "-o" << m_encodePath;
arguments << "-e" << "x264";
arguments << "-b" << "500";
+ arguments << "-2" << "-T";
arguments << "-E" << "faac";
arguments << "-B" << "96";
arguments << "-R" << "auto";
arguments << "-6" << "stereo";
arguments << "-N" << "eng" << "--native-dub";
arguments << "-f" << "mp4";
- arguments << "-P" << "-2" << "-T";
+ arguments << "--loose-anamorphic" << "--modulus" << "16";
arguments << "--optimize" << "--decomb" << "--deblock" << "--denoise=\"weak\"";
arguments << "-x" << "ref=3:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:subme=9:analyse=all:8x8dct:trellis=1:no-fast-pskip:psy-rd=1,1";
- process.start(QLatin1String("HandBrakeCLI"), arguments, QIODevice::ReadOnly);
+ qDebug() << "starting handbreak with arguments:" << arguments;
+ //process.setStandardErrorFile("/home/zx2c4/Desktop/error.log");
+ //process.setStandardOutputFile("/home/zx2c4/Desktop/out.log");
+ process.start(QLatin1String("./HandBrakeCLI"), arguments, QIODevice::ReadOnly);
if (!process.waitForStarted())
return false;
QTextStream reader(&process);
- QRegExp percentLinePattern(QLatin1String("^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\\.[0-9]*) %( \\(([0-9]*\\.[0-9]*) fps, avg ([0-9]*\\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\\))?"));
+ QRegExp percentLinePattern(QLatin1String("^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\\.[0-9]*) % (\\(([0-9]*\\.[0-9]*) fps, avg ([0-9]*\\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\\))?"));
+ QRegExp lessPercentLinePattern(QLatin1String("^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\\.[0-9]*) %"));
while (process.waitForReadyRead(-1)) {
- if (percentLinePattern.exactMatch(reader.readLine())) {
- qDebug() << percentLinePattern.capturedTexts(); //cap(n)
+ QString line = reader.readLine().trimmed();
+ if (percentLinePattern.exactMatch(line)) {
+ QStringList captured = percentLinePattern.capturedTexts();
+ int currentTask = captured.at(1).toInt();
+ int totalTasks = captured.at(2).toInt();
+ float percent = captured.at(3).toFloat();
+ float currentFps = captured.at(5).toFloat();
+ float avgFps = captured.at(6).toFloat();
+ QTime timeRemaining(captured.at(7).toInt(), captured.at(8).toInt(), captured.at(9).toInt());
+ emit encodeProgress(currentTask, totalTasks, percent, currentFps, avgFps, timeRemaining);
+ } else if(lessPercentLinePattern.exactMatch(line)) {
+ QStringList captured = lessPercentLinePattern.capturedTexts();
+ int currentTask = captured.at(1).toInt();
+ int totalTasks = captured.at(2).toInt();
+ float percent = captured.at(3).toFloat();
+ emit encodeProgress(currentTask, totalTasks, percent, -1, -1, QTime());
}
}
- return process.waitForFinished(-1);
+ process.waitForFinished(-1);
+ return process.exitStatus() == QProcess::NormalExit;
}
QWidget* EncodeMP4Job::gui()
{
- //TODO: make a gui
- return new QLabel("Encode mp4 place holder, foo!");
+ return new EncodeMP4JobGui(this);
}
diff --git a/encodemp4job.h b/encodemp4job.h
index d82bbd0..592922f 100644
--- a/encodemp4job.h
+++ b/encodemp4job.h
@@ -3,6 +3,7 @@
#include "job.h"
#include "video.h"
+#include <QTime>
class EncodeMP4Job : public Job
{
@@ -17,7 +18,7 @@ private:
QString m_encodePath;
QString m_imagePath;
signals:
- void encodePercentage(float percentage);
+ void encodeProgress(int currentTask, int totalTasks, float percent, float currentFps, float avgFps, QTime timeRemaining);
};
#endif // ENCODEMP4JOB_H
diff --git a/mainwindow.cpp b/mainwindow.cpp
index aa20310..dd66ced 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -26,10 +26,6 @@ MainWindow::MainWindow()
heading->addWidget(new QLabel(tr("<b>Videos in Queue</b>")), 1);
m_currentlyInserted = new QPushButton;
connect(m_currentlyInserted, SIGNAL(clicked()), this, SLOT(newVideoFromDVD()));
- if (DVDDrive::instance()->dvdInserted())
- dvdAdded();
- else
- dvdRemoved();
heading->addWidget(m_currentlyInserted);
QVBoxLayout *layout = new QVBoxLayout;
layout->addLayout(heading);
@@ -41,8 +37,12 @@ MainWindow::MainWindow()
if (video->isJobCompleted(Video::DVDImage))
addVideo(video);
else
- settings.remove(QString("Videos/%1").arg(title));
+ settings.remove(title);
}
+ if (DVDDrive::instance()->dvdInserted())
+ dvdAdded();
+ else
+ dvdRemoved();
setLayout(layout);
}
void MainWindow::dvdAdded()
@@ -75,6 +75,6 @@ void MainWindow::runningJob(Job *job)
}
void MainWindow::completedJob(bool success)
{
- //TODO: do something with success
+ //TODO: do something with [lack of] success
delete qobject_cast<Job*>(sender())->widget();
}