commit 742b539d04a273e359841e271745f69d23b0cbd3 Author: chenyf <1343619937@qq.com> Date: Mon Sep 9 19:33:41 2024 +0800 frist_version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d163863 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..43d9a2c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "cmake.generator": "MinGW Makefiles", + "files.associations": { + "ostream": "cpp", + "iostream": "cpp" + } +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5bb8c2e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 3.5) + +project(ffmpeg_cilent LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# QtCreator supports the following variables for Android, which are identical to qmake Android variables. +# Check http://doc.qt.io/qt-5/deployment-android.html for more information. +# They need to be set before the find_package(Qt5 ...) call. + +#if(ANDROID) +# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") +# if (ANDROID_ABI STREQUAL "armeabi-v7a") +# set(ANDROID_EXTRA_LIBS +# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so +# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so) +# endif() +#endif() + +find_package(Qt5 COMPONENTS Widgets REQUIRED) + +if(ANDROID) + add_library(ffmpeg_cilent SHARED + WIN32 + main.cpp + mainwindow.cpp + mainwindow.h + mainwindow.ui + ) +else() + add_executable(ffmpeg_cilent + main.cpp + mainwindow.cpp + mainwindow.h + mainwindow.ui + ) +endif() + +target_link_libraries(ffmpeg_cilent PRIVATE Qt5::Widgets) diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user new file mode 100644 index 0000000..617ee04 --- /dev/null +++ b/CMakeLists.txt.user @@ -0,0 +1,642 @@ + + + + + + EnvironmentId + {2af8b88c-e5ba-4fff-b554-68f1c16ee860} + + + ProjectExplorer.Project.ActiveTarget + 1 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + Builtin.Questionable + + true + Builtin.DefaultTidyAndClazy + 8 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.12.9 MinGW 64-bit + Desktop Qt 5.12.9 MinGW 64-bit + qt.qt5.5129.win64_mingw73_kit + 1 + 0 + 0 + + + CMAKE_BUILD_TYPE:STRING=Debug + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + D:\WORK\QT\build-ffmpeg_cilent-Desktop_Qt_5_12_9_MinGW_64_bit-Debug + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=Release + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + D:\WORK\QT\build-ffmpeg_cilent-Desktop_Qt_5_12_9_MinGW_64_bit-Release + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=RelWithDebInfo + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + D:\WORK\QT\build-ffmpeg_cilent-Desktop_Qt_5_12_9_MinGW_64_bit-RelWithDebInfo + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release with Debug Information + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=MinSizeRel + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + D:\WORK\QT\build-ffmpeg_cilent-Desktop_Qt_5_12_9_MinGW_64_bit-MinSizeRel + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 4 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + ffmpeg_cilent + CMakeProjectManager.CMakeRunConfiguration.ffmpeg_cilent + ffmpeg_cilent + + false + + false + true + true + false + false + true + + D:/WORK/QT/build-ffmpeg_cilent-Desktop_Qt_5_12_9_MinGW_64_bit-Release + + 1 + + + + ProjectExplorer.Project.Target.1 + + mingw-gcc + mingw-gcc + {70298f91-1f6a-4f9c-afc0-abb5d1400c4a} + 1 + 0 + 0 + + + CMAKE_BUILD_TYPE:STRING=Debug + CMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + + 2 + D:\WORK\QT\build-ffmpeg_cilent-mingw_gcc-Debug + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=Release + CMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + + 2 + D:\WORK\QT\build-ffmpeg_cilent-mingw_gcc-Release + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=RelWithDebInfo + CMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + + 2 + D:\WORK\QT\build-ffmpeg_cilent-mingw_gcc-RelWithDebInfo + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release with Debug Information + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=MinSizeRel + CMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + + 2 + D:\WORK\QT\build-ffmpeg_cilent-mingw_gcc-MinSizeRel + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 4 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + ffmpeg_cilent + CMakeProjectManager.CMakeRunConfiguration.ffmpeg_cilent + ffmpeg_cilent + + false + + false + true + true + false + false + true + + D:/WORK/QT/build-ffmpeg_cilent-mingw_gcc-Release + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..fd3e533 --- /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..c01b7e2 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,165 @@ +#include "mainwindow.h" +#include "./ui_mainwindow.h" +#include +#include +#include + +using namespace std; +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), ui(new Ui::MainWindow) +{ + ui->setupUi(this); + // 选择修改分辨率 + connect(ui->en_mdf_res, SIGNAL(stateChanged(int)), this, SLOT(en_mdf_res_state_change(int))); + en_mdf_res_state_change(Qt::Unchecked); + // bt_browse_press + connect(ui->bt_browse, SIGNAL(clicked()), this, SLOT(press_bt_browse())); + // bt_start_change + connect(ui->bt_start_change, SIGNAL(clicked()), this, SLOT(ffmpeg_run())); + //ffmpeg_info + connect(&ffmpeg_process, SIGNAL(readyReadStandardOutput()), this, SLOT(ffmpeg_info_read())); + // def_cfg + connect(ui->bt_def_cfg, SIGNAL(clicked()), this, SLOT(def_cfg())); + // hor_change + connect(ui->bt_hor_change, SIGNAL(clicked()), this, SLOT(hor_change_event())); + // ver_change + connect(ui->bt_ver_change, SIGNAL(clicked()), this, SLOT(ver_change_event())); +} +void MainWindow::hor_change_event() +{ + ui->hor_val->setText("-1"); +} +void MainWindow::ver_change_event() +{ + ui->ver_val->setText("-1"); +} +void MainWindow::ffmpeg_info_read() +{ + cout << "ffmpeg_info_read" << endl; + QString ffmpeg_info = ffmpeg_process.readAllStandardOutput(); + if (ffmpeg_info.isEmpty()) + { + cout << "No output from ffmpeg" << endl; + } + else + { + ui->lb_info->setText(ffmpeg_info); + ui->lb_info->repaint(); + cout << "ffmpeg_info: " << ffmpeg_info.toStdString() << endl; + } +} +void MainWindow::def_cfg(){ + en_mdf_res_state_change(Qt::Checked); + ui->en_mdf_res->setChecked(true); + ui->hor_val->setText("640"); + ui->ver_val->setText("-1"); + ui->cb_fps_change->setChecked(true); + ui->le_fps_val->setText("5"); +} +void MainWindow::ffmpeg_run() +{ + cout << "ffmpeg_run" << endl; + // deal cmd + QString cmd = "./ffmpeg.exe -i "; + if (ui->le_src_file->text().isEmpty()) + { + cout << "src file is empty" << endl; + return; + } + cmd += ui->le_src_file->text(); + if (ui->cb_fps_change->isChecked()) + { + cmd += " -r "; + cmd += ui->le_fps_val->text(); + } + if (ui->en_mdf_res->isChecked()) + { + cmd += " -vf scale="; + cmd += ui->hor_val->text(); + cmd += ":"; + cmd += ui->ver_val->text(); + } + if (ui->le_dest_file->text().isEmpty()) + { + cout << "dest file is empty" << endl; + return; + } + cmd += " "; + cmd += ui->le_dest_file->text(); + cmd += ui->cb_dest_file_end->currentText(); + cout << "cmd: " << cmd.toStdString() << endl; + + + ffmpeg_process.setProcessChannelMode(QProcess::MergedChannels); + ffmpeg_process.start(cmd); + if (!ffmpeg_process.waitForStarted()) + { + cout << "ffmpeg_run failed to start" << endl; + return; + } + + + while (!ffmpeg_process.waitForFinished()) + { + // QString ffmpeg_info = ffmpeg_process.readAll(); + // cout << "ffmpeg_info: " << ffmpeg_info.toStdString() << endl; + // ui->lb_info->setText(ffmpeg_info); + // _sleep(1); + } + + QMessageBox::information(this, "提示", "转换完成!"); + // QString ffmpeg_info = ffmpeg_process.readAllStandardOutput(); + // if (ffmpeg_info.isEmpty()) + // { + // cout << "No output from ffmpeg" << endl; + // } + // else + // { + // ui->lb_info->setText(ffmpeg_info); + // cout << "ffmpeg_info: " << ffmpeg_info.toStdString() << endl; + // } +} +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::en_mdf_res_state_change(int state) +{ + cout << "en_mdf_res_state_change" << endl; + if (state == Qt::Checked) + { + this->ui->hor_val->setFocusPolicy(Qt::StrongFocus); + this->ui->hor_val->setEnabled(true); + this->ui->hor_val->setStyleSheet("background-color: white;"); + this->ui->ver_val->setFocusPolicy(Qt::StrongFocus); + this->ui->ver_val->setEnabled(true); + this->ui->ver_val->setStyleSheet("background-color: white;"); + } + else + { + this->ui->hor_val->setFocusPolicy(Qt::NoFocus); + this->ui->hor_val->setEnabled(false); + this->ui->hor_val->setText(""); + this->ui->hor_val->setStyleSheet("background-color: gray;"); + this->ui->ver_val->setFocusPolicy(Qt::NoFocus); + this->ui->ver_val->setEnabled(false); + this->ui->ver_val->setText(""); + this->ui->ver_val->setStyleSheet("background-color: gray;"); + } +} + +void MainWindow::press_bt_browse() +{ + QString select_file = QFileDialog::getOpenFileName(this, tr("选择一个目录"), tr("*.*")); + + if (!select_file.isEmpty()) + { + // 用户选择了一个目录,处理选择的路径 + // 这里可以是输出到控制台或其他操作 + ui->le_src_file->setText(select_file); + QFileInfo file_info(select_file); + QString baseName = file_info.completeBaseName(); // 获取不带扩展名的文件名 + ui->le_dest_file->setText(file_info.path()+tr("/")+baseName); + } +} \ No newline at end of file diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..4572ecd --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,31 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); +public slots: + void en_mdf_res_state_change(int state); + void press_bt_browse(); + void ffmpeg_run(); + void ffmpeg_info_read(); + void def_cfg(); + void hor_change_event(); + void ver_change_event(); +private: + Ui::MainWindow *ui; + QProcess ffmpeg_process; +}; +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..2cf788c --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,297 @@ + + + MainWindow + + + + 0 + 0 + 975 + 729 + + + + MainWindow + + + + + + + background-color: rgb(255, 255, 127); + + + + + + + + + 修改帧率 + + + + + + + 帧率: + + + + + + + background-color: rgb(255, 255, 255); + + + + + + + + + + + + + + 16777215 + 90 + + + + background-color: rgb(170, 255, 255); + + + + + + + + + background-color: rgb(255, 255, 255); + + + + + + + background-color: rgb(255, 255, 255); + + + + .gif + + + + + + + + background-color: rgb(255, 255, 255); + + + + + + + src_file: + + + + + + + background-color: rgb(255, 255, 255); + + + 浏览 + + + + + + + dest_file: + + + + + + + + + + + 400 + 16777215 + + + + background-color: rgb(255, 255, 127); + + + + + + + + + + + 水平分辨率 + + + + + + + background-color: rgb(255, 255, 255); + + + + + + + color: rgb(0, 0, 0); +background-color: rgb(255, 255, 255); + + + + + + + 垂直分辨率 + + + + + + + 修改分辨率 + + + + + + + + 60 + 16777215 + + + + background-color: rgb(255, 255, 255); + + + 跟随 + + + + + + + + 60 + 16777215 + + + + background-color: rgb(255, 255, 255); + + + 跟随 + + + + + + + + + + + + background-color: rgb(255, 255, 127); + + + + + + + + + background-color: rgb(255, 85, 255); + + + 生成 + + + + + + + + + + 1920 + 640 + + + + background-color: rgb(255, 255, 255); + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + background-color: rgb(255, 255, 255); +background-color: rgb(255, 170, 255); + + + 默认配置 + + + + + + + + 16777215 + 20 + + + + excute info: + + + + + + + + + + + + 0 + 0 + 975 + 26 + + + + + + + +