Repository navigation
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
85 lines (76 loc) · 2.46 KB
/
Copy pathmainwindow.cpp
File metadata and controls
85 lines (76 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "transcoder/transcoder.h"
#include <QCloseEvent>
#include <QFileDialog>
#include <QDir>
#include <QSettings>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QSettings s;
s.beginGroup("TRANSCODE");
ui->lineEdit->setText(s.value("VIDEO").toString());
transcoder = nullptr;
progressDlg = new ProgressWidget(ui->widget);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::closeEvent(QCloseEvent *event)
{
if(transcoder && transcoder->isTranscoding())
{
transcoder->stop();
}
event->accept();
}
void MainWindow::showImage(const QImage& image)
{
ui->label->setPixmap(QPixmap::fromImage(image).scaled(ui->label->width(), ui->label->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
void MainWindow::on_pushButton_clicked()
{
if(transcoder != nullptr)
{
transcoder->stop();
transcoder = nullptr;
}
else {
VideoSource r;
r.fileName = ui->lineEdit->text();
r.frameCount = 30000;
r.entryPoint = 0;
r.duration = 29900;
QList<VideoSource> list = QList<VideoSource>() << r;
TranscoderOption params;
params.sourceInfo.filename = r.fileName.toStdString();
params.sourceInfo.startFrame = 0;
params.sourceInfo.endFrame = 500;
params.encodingThreadCount = 5;
params.outputFilename = "ThisIsTestOutputFileName.mxf";
transcoder = new Transcoder(params);
connect(transcoder, &Transcoder::imageReady, this, &MainWindow::showImage);
connect(transcoder, &Transcoder::currentProgress, progressDlg, &ProgressWidget::setProgress);
connect(transcoder, &Transcoder::currentProgressText, progressDlg, &ProgressWidget::setProgressText);
transcoder->start();
}
}
void MainWindow::on_pushButton_3_clicked()
{
QFile style_file("D:\\qss\\style.qss");
style_file.open(QFile::ReadOnly | QIODevice::Text);
qApp->setStyleSheet(QString::fromUtf8(style_file.readAll()));
}
void MainWindow::on_pushButton_4_clicked()
{
QSettings s;
s.beginGroup("TRANSCODE");
QString filename = QFileDialog::getOpenFileName(this, "xx", s.value("VIDEO").toString());
if(filename.isEmpty()) return;
ui->lineEdit->setText(filename);
s.setValue("VIDEO", ui->lineEdit->text());
}