From aa59fb43efb0c73d9c527bf29f4c45fcc9485cbc Mon Sep 17 00:00:00 2001 From: JDM170 <30170278+JDM170@users.noreply.github.com> Date: Tue, 5 May 2020 22:53:51 +0700 Subject: [PATCH] Initial --- .gitignore | 2 + README.md | 5 + main.cpp | 11 ++ mainwindow.cpp | 63 ++++++++++++ mainwindow.h | 35 +++++++ mainwindow.ui | 266 +++++++++++++++++++++++++++++++++++++++++++++++++ radio1.pro | 31 ++++++ 7 files changed, 413 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 main.cpp create mode 100644 mainwindow.cpp create mode 100644 mainwindow.h create mode 100644 mainwindow.ui create mode 100644 radio1.pro diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3480b4f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pro.* +*.mp3 diff --git a/README.md b/README.md new file mode 100644 index 0000000..a03a303 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Запись радио-потока + +### Использовалось: +* Qt (5.11.1 и выше) +* Google diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..b48f94e --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..fbcc733 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,63 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + my_proc = new QProcess(); + connect(my_proc, SIGNAL(started()), this, SLOT(slotStartedStdout())); + connect(my_proc, SIGNAL(finished(int)), this, SLOT(slotFinishedStdout(int))); +// box = new QMessageBox(); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_pushButton_clicked() +{ + QString directory = QFileDialog::getSaveFileName(this, "Сохранить как...", "D:", "MP3 (*.mp3)"); + ui->directory->setText(directory); + QString + link = " -i " + ui->link->text().toUtf8(), // http://novosibirsk.radiokp32.mp3.streamr.ru, http://air.radiorecord.ru:805/rr_320, etc... + time = " -t " + secondToTime(ui->time->text().toInt()), // 60 second, 120 second, etc... + bitrate = " -ab " + ui->bitrate->currentText(), // 128k, 192k, 256k, 320k, etc... + discretisation = " -ar " + ui->discretisation->currentText(), + strCommand = "ffmpeg\\bin\\ffmpeg.exe " + link + " -acodec libmp3lame " + bitrate + discretisation + time + " " + directory; +// box->setText(strCommand); // Debug +// box->exec(); // Debug + my_proc->start(strCommand); +} + +void MainWindow::slotStartedStdout() { + ui->textEdit->append("Идет запись!"); +} + +void MainWindow::slotFinishedStdout(int code) { + if(code == 0) { + ui->textEdit->append("Запись завершена!\n"); + } + else if(code == 1) { + ui->textEdit->append("Ошибка!\n"); + QString error = my_proc->readAllStandardError(); + ui->textEdit->append(error); + } +} + +QString MainWindow::secondToTime(int i_time) { + QString time; + if(i_time < 60) { + time = "00:00:" + QString::number(i_time); + } + else { + int minute = i_time / 60, hour = minute / 60; + time = QString::number(hour) + ":" + + QString::number(minute - 60*hour) + ":" + + QString::number(i_time - 60*minute); + } + return time; +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..a1806c0 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,35 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +//#include + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + QString secondToTime(int); + +private slots: + void on_pushButton_clicked(); + void slotStartedStdout(); + void slotFinishedStdout(int); + +private: + Ui::MainWindow *ui; + QProcess *my_proc; +// QMessageBox *box; +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..9c02d74 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,266 @@ + + + MainWindow + + + true + + + + 0 + 0 + 560 + 250 + + + + + 560 + 250 + + + + + 560 + 250 + + + + Запись онлайн-радио + + + + + + 10 + 0 + 241 + 41 + + + + + Times New Roman + 18 + 75 + true + + + + Запись онлайн-радио + + + + + + 400 + 40 + 151 + 141 + + + + true + + + + + + 220 + 190 + 161 + 51 + + + + + Times New Roman + 16 + + + + Запись + + + + + + 140 + 160 + 151 + 20 + + + + true + + + + + + 10 + 160 + 101 + 16 + + + + Путь сохранения: + + + + + + 10 + 70 + 81 + 16 + + + + Время записи: + + + + + + 140 + 70 + 151 + 20 + + + + + + + 400 + 10 + 151 + 21 + + + + + 16 + + + + Лог действий + + + + + + 10 + 40 + 121 + 16 + + + + Ссылка на трансляцию: + + + + + + 140 + 40 + 241 + 20 + + + + + + + 10 + 100 + 61 + 16 + + + + Битрейт: + + + + + + 140 + 100 + 151 + 22 + + + + + 128k + + + + + 192k + + + + + 256k + + + + + 320k + + + + + + + 10 + 130 + 131 + 16 + + + + Частота дискретизации: + + + + + + 140 + 130 + 151 + 22 + + + + + 44100 + + + + + 48000 + + + + + 96000 + + + + + 192000 + + + + + + + + + diff --git a/radio1.pro b/radio1.pro new file mode 100644 index 0000000..218fa79 --- /dev/null +++ b/radio1.pro @@ -0,0 +1,31 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2017-11-23T09:07:29 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = radio1 +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which as been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui