summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2009-09-26 05:17:37 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2009-09-26 05:17:37 -0400
commit2bb77bf0c2b479475e559dd27d8eddcef9fd5ca0 (patch)
tree869a4279ef5e1f729b9db96bc3ea69c89542c5a7
parentAdd handbrake snapshot build. (diff)
downloadAnyRip-2bb77bf0c2b479475e559dd27d8eddcef9fd5ca0.tar.xz
AnyRip-2bb77bf0c2b479475e559dd27d8eddcef9fd5ca0.zip
Encoding skeleton and cleanups.
-rw-r--r--dvdimagejobgui.cpp2
-rw-r--r--encodemp4job.cpp33
-rw-r--r--encodemp4job.h2
-rw-r--r--job.cpp9
-rw-r--r--job.h4
-rw-r--r--mainwindow.cpp2
-rw-r--r--videogui.cpp1
-rw-r--r--videogui.h4
-rw-r--r--videoqueue.cpp10
9 files changed, 53 insertions, 14 deletions
diff --git a/dvdimagejobgui.cpp b/dvdimagejobgui.cpp
index 7041ebc..5f22b80 100644
--- a/dvdimagejobgui.cpp
+++ b/dvdimagejobgui.cpp
@@ -14,7 +14,7 @@ DVDImageJobGui::DVDImageJobGui(DVDImageJob *job) :
m_progressBar = new QProgressBar;
m_progressLabel = new QLabel;
QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(new QLabel(tr("<b>Copying DVD ISO</b>")));
+ layout->addWidget(new QLabel(tr("<b>Copying DVD ISO</b> of <i>%1</i>").arg(job->video()->title())));
layout->addWidget(m_progressBar);
layout->addWidget(m_progressLabel);
setLayout(layout);
diff --git a/encodemp4job.cpp b/encodemp4job.cpp
index 34b82f9..d056002 100644
--- a/encodemp4job.cpp
+++ b/encodemp4job.cpp
@@ -1,6 +1,10 @@
#include "encodemp4job.h"
#include <QWidget>
#include <QLabel>
+#include <QProcess>
+#include <QStringList>
+#include <QTextStream>
+#include <QRegExp>
EncodeMP4Job::EncodeMP4Job(Video *video, QString encodePath, QString imagePath) :
Job(video),
@@ -14,9 +18,32 @@ Video::Jobs EncodeMP4Job::jobType() const
}
bool EncodeMP4Job::executeJob()
{
- //TODO: encode the actual mp4!
- sleep(5);
- return true;
+ QProcess process;
+ QStringList arguments;
+ arguments << "-i" << m_imagePath;
+ arguments << "-o" << m_encodePath;
+ arguments << "-e" << "x264";
+ arguments << "-b" << "500";
+ 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 << "--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);
+ 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\\))?"));
+ while (process.waitForReadyRead(-1)) {
+ if (percentLinePattern.exactMatch(reader.readLine())) {
+ qDebug() << percentLinePattern.capturedTexts(); //cap(n)
+ }
+ }
+ return process.waitForFinished(-1);
}
QWidget* EncodeMP4Job::gui()
{
diff --git a/encodemp4job.h b/encodemp4job.h
index 41eef3b..d82bbd0 100644
--- a/encodemp4job.h
+++ b/encodemp4job.h
@@ -16,6 +16,8 @@ protected:
private:
QString m_encodePath;
QString m_imagePath;
+signals:
+ void encodePercentage(float percentage);
};
#endif // ENCODEMP4JOB_H
diff --git a/job.cpp b/job.cpp
index ae3a9e2..af35104 100644
--- a/job.cpp
+++ b/job.cpp
@@ -2,14 +2,19 @@
#include "video.h"
#include <QtConcurrentRun>
-Job::Job(QObject *parent)
+Job::Job(Video *parent)
: QObject(parent),
- m_gui(0)
+ m_gui(0),
+ m_video(parent)
{
m_watcher = new QFutureWatcher<bool>;
m_watcher->setParent(this);
connect(m_watcher, SIGNAL(finished()), this, SLOT(jobFinished()));
}
+Video* Job::video() const
+{
+ return m_video;
+}
void Job::runJob()
{
m_watcher->setFuture(QtConcurrent::run(this, &Job::executeJob));
diff --git a/job.h b/job.h
index e7b824d..9b276ca 100644
--- a/job.h
+++ b/job.h
@@ -13,13 +13,15 @@ public:
void runJob();
virtual Video::Jobs jobType() const = 0;
QWidget* widget();
+ Video* video() const;
protected:
- Job(QObject *parent = 0);
+ Job(Video *parent);
virtual bool executeJob() = 0;
virtual QWidget* gui() = 0;
private:
QFutureWatcher<bool> *m_watcher;
QWidget *m_gui;
+ Video *m_video;
private slots:
void jobFinished();
signals:
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 147514a..aa20310 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -40,6 +40,8 @@ MainWindow::MainWindow()
Video *video = new Video(title, this);
if (video->isJobCompleted(Video::DVDImage))
addVideo(video);
+ else
+ settings.remove(QString("Videos/%1").arg(title));
}
setLayout(layout);
}
diff --git a/videogui.cpp b/videogui.cpp
index d0b2e95..02aad03 100644
--- a/videogui.cpp
+++ b/videogui.cpp
@@ -34,6 +34,7 @@ VideoGui::VideoGui(Video *video) :
layout->addWidget(m_subtitleCheck);
layout->addWidget(m_posterCheck);
setLayout(layout);
+ setFrameStyle(QFrame::StyledPanel);
}
void VideoGui::jobCompleted(Video::Jobs jobType, bool success)
{
diff --git a/videogui.h b/videogui.h
index d087b85..58e20ad 100644
--- a/videogui.h
+++ b/videogui.h
@@ -1,12 +1,12 @@
#ifndef VIDEOGUI_H
#define VIDEOGUI_H
-#include <QWidget>
+#include <QFrame>
#include "video.h"
class QCheckBox;
class Video;
-class VideoGui : public QWidget
+class VideoGui : public QFrame
{
Q_OBJECT
public:
diff --git a/videoqueue.cpp b/videoqueue.cpp
index f4eb639..468d17a 100644
--- a/videoqueue.cpp
+++ b/videoqueue.cpp
@@ -9,11 +9,11 @@ VideoQueue::VideoQueue(QObject *parent) :
QObject(parent),
m_jobQueues(QVector<JobQueue*>(4))
{
- m_jobQueues.insert(Video::DVDImage, new JobQueue(this));
- m_jobQueues.insert(Video::EncodeMP4, new JobQueue(this));
- m_jobQueues.insert(Video::Upload, new JobQueue(this));
- m_jobQueues.insert(Video::TitleLoad, new JobQueue(this));
- foreach(JobQueue *queue, m_jobQueues)
+ m_jobQueues.replace(Video::DVDImage, new JobQueue(this));
+ m_jobQueues.replace(Video::EncodeMP4, new JobQueue(this));
+ m_jobQueues.replace(Video::Upload, new JobQueue(this));
+ m_jobQueues.replace(Video::TitleLoad, new JobQueue(this));
+ foreach (JobQueue *queue, m_jobQueues)
connect(queue, SIGNAL(runningJob(Job*)), this, SIGNAL(runningJob(Job*)));
}
void VideoQueue::newVideo(Video *video)