private:
Q_OBJECT
//...
class MyQTForm : public QMainWindow {
private:
Q_OBJECT
QProcess *process;
//...
To copy to clipboard, switch view to plain text mode
Now the part I want to process:
void MyQTForm::cb_process_dir(const QString& _in, const QString& _out) {
filters << "*.mp3" << "*.flv" << "*.mp4";
int index = 0;
int total = dir_list.size();
for (; index < total; index++) {
cb_process (file_in, file_out); // a lot of files to process
}
}
void MyQTForm::cb_process (const QString& file_in, const QString& file_out) {
QTextStream(&cmd
) <<
"ffmpeg -i \"" << file_in <<
"\" -f mp3 -ab 128k \"" << file_out <<
"\"";
process->setStandardOutputFile(tr("/dev/null"));
connect(process, SIGNAL(started()),this, SLOT(onProcessStarted ()));
connect(process,
SIGNAL(finished
(int,
QProcess::ExitStatus)),
this,
SLOT(onProcessEnded
()));
connect(process,
SIGNAL(finished
(int,
QProcess::ExitStatus)), process,
SLOT(deleteLater
()) );
process->start(cmd);
}
void MyQTForm::onProcessStarted() {
activo = true;
menuBar()->setEnabled(!activo);
statusBar()->showMessage(tr("Convirtiendo..."));
}
void MyQTForm::onProcessEnded() {
activo = false;
menuBar()->setEnabled(!activo);
if (check1->isChecked()) {
//QFile::remove (_out_file_tmp);
}
statusBar()->showMessage(tr("Hecho"));
}
void MyQTForm::cb_process_dir(const QString& _in, const QString& _out) {
QDir in_dir (_in);
QStringList filters;
filters << "*.mp3" << "*.flv" << "*.mp4";
QStringList dir_list = in_dir.entryList (filters);
int index = 0;
int total = dir_list.size();
for (; index < total; index++) {
QString file_in = _in + QString("/") + dir_list[index];
QFileInfo fi(file_in);
QString file_out = _out + QString("/") + fi.baseName() + QString(".mp3");
cb_process (file_in, file_out); // a lot of files to process
}
}
void MyQTForm::cb_process (const QString& file_in, const QString& file_out) {
QString cmd;
QTextStream(&cmd) << "ffmpeg -i \"" << file_in << "\" -f mp3 -ab 128k \"" << file_out << "\"";
process = new QProcess(this);
process->setStandardOutputFile(tr("/dev/null"));
connect(process, SIGNAL(started()),this, SLOT(onProcessStarted ()));
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)),this, SLOT(onProcessEnded ()));
connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), process, SLOT(deleteLater()) );
process->start(cmd);
}
void MyQTForm::onProcessStarted() {
activo = true;
menuBar()->setEnabled(!activo);
statusBar()->showMessage(tr("Convirtiendo..."));
}
void MyQTForm::onProcessEnded() {
activo = false;
menuBar()->setEnabled(!activo);
if (check1->isChecked()) {
//QFile::remove (_out_file_tmp);
}
statusBar()->showMessage(tr("Hecho"));
}
To copy to clipboard, switch view to plain text mode
This are the results:
Bookmarks