├── bin ├── appicon.ico ├── presets.ini └── config_default.ini ├── ui ├── overlay_widget.cpp ├── overlay_widget.hpp └── mainwindow.ui ├── core ├── formats │ ├── codec.hpp │ ├── container.hpp │ ├── format_support.hpp │ ├── format_support_loader.hpp │ ├── metadata.hpp │ ├── ffmpeg_format_support_loader.hpp │ ├── metadata_loader.hpp │ ├── ffmpeg_format_support_loader.cpp │ └── metadata_loader.cpp ├── notifier │ ├── notifier.hpp │ ├── message_box_notifier.hpp │ ├── message.hpp │ └── message_box_notifier.cpp ├── utils │ ├── platform_info.hpp │ ├── warnings.hpp │ ├── warnings.cpp │ └── platform_info.cpp ├── settings │ ├── settings.hpp │ ├── ini_settings.hpp │ ├── ini_settings.cpp │ ├── serializer.hpp │ └── serializer.cpp ├── encoder │ ├── encoder_options.hpp │ ├── encoder_options_builder.hpp │ ├── encoder.hpp │ ├── encoder_options_builder.cpp │ └── encoder.cpp ├── main.cpp ├── mainwindow.hpp └── mainwindow.cpp ├── .clang-format ├── .gitignore ├── flake.nix ├── flake.lock ├── CMakeLists.txt ├── README.md └── LICENSE.md /bin/appicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thurinum/simple-media-encoder/HEAD/bin/appicon.ico -------------------------------------------------------------------------------- /ui/overlay_widget.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Thurinum on 2024-08-18. 3 | // 4 | 5 | #include "overlay_widget.hpp" 6 | -------------------------------------------------------------------------------- /core/formats/codec.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CODEC_H 2 | #define CODEC_H 3 | 4 | #include 5 | #include 6 | 7 | struct Codec { 8 | QString displayName; 9 | QString libraryName; 10 | bool isAudioCodec; 11 | }; 12 | 13 | Q_DECLARE_METATYPE(Codec) 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /core/formats/container.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CONTAINER_H 2 | #define CONTAINER_H 3 | 4 | #include 5 | #include 6 | 7 | struct Codec; 8 | 9 | struct Container { 10 | QString displayName; 11 | QString formatName; 12 | }; 13 | 14 | Q_DECLARE_METATYPE(Container) 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /core/formats/format_support.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FORMAT_SUPPORT_H 2 | #define FORMAT_SUPPORT_H 3 | 4 | #include "codec.hpp" 5 | #include "container.hpp" 6 | 7 | struct FormatSupport { 8 | const QList videoCodecs; 9 | const QList audioCodecs; 10 | const QList containers; 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /core/notifier/notifier.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NOTIFIER_H 2 | #define NOTIFIER_H 3 | 4 | #include 5 | 6 | #include "message.hpp" 7 | 8 | class Notifier 9 | { 10 | public: 11 | virtual void Notify(const Message& message) const = 0; 12 | virtual void Notify(Severity severity, const QString& title, const QString& message, const QString& details = "") const = 0; 13 | }; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: WebKit 2 | --- 3 | Language: Cpp 4 | AlignAfterOpenBracket: BlockIndent 5 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 6 | BreakBeforeBraces: Allman 7 | AlignOperands: AlignAfterOperator 8 | AllowAllArgumentsOnNextLine: true 9 | AllowAllParametersOfDeclarationOnNextLine: true 10 | AllowShortLambdasOnASingleLine: Empty 11 | LambdaBodyIndentation: OuterScope 12 | 13 | -------------------------------------------------------------------------------- /core/utils/platform_info.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_INFO_HPP 2 | #define PLATFORM_INFO_HPP 3 | 4 | #include 5 | #include 6 | 7 | class PlatformInfo 8 | { 9 | public: 10 | PlatformInfo(); 11 | 12 | bool isWindows() const { return m_isWindows; }; 13 | bool isNvidia() const { return m_isNvidia; }; 14 | 15 | private: 16 | bool DetectNvidia() const; 17 | 18 | const bool m_isWindows = QSysInfo::kernelType() == "winnt"; 19 | bool m_isNvidia; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /core/formats/format_support_loader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FORMAT_SUPPORT_LOADER_H 2 | #define FORMAT_SUPPORT_LOADER_H 3 | 4 | #include 5 | 6 | #include "format_support.hpp" 7 | #include "core/notifier/notifier.hpp" 8 | 9 | class FormatSupportLoader : public QObject 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | virtual void QuerySupportedFormatsAsync() = 0; 15 | 16 | signals: 17 | void queryCompleted(std::variant, Message> maybeFormats); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /core/settings/settings.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct Settings { 6 | virtual ~Settings() = default; 7 | 8 | [[nodiscard]] virtual QVariant get(const QString& key) const = 0; 9 | virtual void Set(const QString& key, const QVariant& value) = 0; 10 | 11 | [[nodiscard]] virtual QStringList groups() const = 0; 12 | [[nodiscard]] virtual QStringList keysInGroup(const QString& group) const = 0; 13 | [[nodiscard]] virtual QString fileName() const = 0; 14 | }; 15 | -------------------------------------------------------------------------------- /core/utils/warnings.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WARNINGS_HPP 2 | #define WARNINGS_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Warnings 9 | { 10 | public: 11 | Warnings(QWidget* widget); 12 | 13 | void Add(const QString& key, const QString& text); 14 | void Remove(const QString& key); 15 | 16 | private: 17 | void UpdateWidget() const; 18 | 19 | QWidget* m_tooltipWidget; 20 | QHash m_warnings; 21 | }; 22 | 23 | #endif // WARNINGS_HPP 24 | -------------------------------------------------------------------------------- /core/formats/metadata.hpp: -------------------------------------------------------------------------------- 1 | #ifndef METADATA_HPP 2 | #define METADATA_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct Metadata { 10 | double width; 11 | double height; 12 | double sizeKbps; 13 | double audioBitrateKbps; 14 | double durationSeconds; 15 | double aspectRatioX; 16 | double aspectRatioY; 17 | double frameRate; 18 | QString videoCodec; 19 | QString audioCodec; 20 | QString container; 21 | }; 22 | #endif // METADATA_HPP 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build system per-user config 2 | *.pro.user 3 | Makefile 4 | CMakeLists.txt.user 5 | cmake_install.cmake 6 | CMakeCache.txt 7 | CMakeFiles/ 8 | .qt/ 9 | 10 | # Build artifacts 11 | cmake-build-*/ 12 | build/ 13 | .qtc_clangd/ 14 | SimpleMediaEncoder_autogen/ 15 | 16 | # Binaries 17 | *.dll 18 | *.exe 19 | # Required as linux binaries do not have an extension 20 | bin/SimpleMediaEncoder 21 | 22 | # Generated custom configuration 23 | bin/config.ini 24 | /config.ini 25 | 26 | # IDE configuration files 27 | .clangd 28 | .vscode/ 29 | .idea/ 30 | -------------------------------------------------------------------------------- /core/notifier/message_box_notifier.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MESSAGE_BOX_NOTIFIER_H 2 | #define MESSAGE_BOX_NOTIFIER_H 3 | 4 | #include "notifier.hpp" 5 | 6 | class MessageBoxNotifier : public Notifier 7 | { 8 | public: 9 | void Notify(const Message& message) const override; 10 | void Notify(Severity severity, const QString& title, const QString& message, const QString& details) const override; 11 | 12 | private: 13 | const QString bugReportPrompt = "

Looks like this issue could be a bug. Kindly report it here."; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /core/utils/warnings.cpp: -------------------------------------------------------------------------------- 1 | #include "warnings.hpp" 2 | 3 | Warnings::Warnings(QWidget* widget) 4 | : m_tooltipWidget { widget } 5 | { 6 | } 7 | 8 | void Warnings::Add(const QString& key, const QString& text) 9 | { 10 | m_warnings.insert(key, text); 11 | UpdateWidget(); 12 | } 13 | 14 | void Warnings::Remove(const QString& key) 15 | { 16 | m_warnings.remove(key); 17 | UpdateWidget(); 18 | } 19 | 20 | void Warnings::UpdateWidget() const 21 | { 22 | if (!m_tooltipWidget) 23 | return; 24 | 25 | const bool hasWarnings = !m_warnings.isEmpty(); 26 | 27 | m_tooltipWidget->setVisible(hasWarnings); 28 | m_tooltipWidget->setToolTip(hasWarnings ? m_warnings.values().join("\n") : ""); 29 | } 30 | -------------------------------------------------------------------------------- /core/settings/ini_settings.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "settings.hpp" 4 | 5 | #include 6 | 7 | class QSettings; 8 | class QString; 9 | 10 | class IniSettings final : public Settings 11 | { 12 | public: 13 | explicit IniSettings(const QString& fileName, const QString& defaultFileName = ""); 14 | 15 | [[nodiscard]] QVariant get(const QString& key) const override; 16 | void Set(const QString& key, const QVariant& value) override; 17 | 18 | [[nodiscard]] QStringList groups() const override; 19 | [[nodiscard]] QStringList keysInGroup(const QString& group) const override; 20 | [[nodiscard]] QString fileName() const override; 21 | 22 | private: 23 | QPointer settings; 24 | QPointer defaultSettings; 25 | }; -------------------------------------------------------------------------------- /bin/presets.ini: -------------------------------------------------------------------------------- 1 | [Default] 2 | aspectRatioSpinBoxH = 0 3 | aspectRatioSpinBoxV = 0 4 | audioCodecComboBox = Passthrough 5 | audioChannelCountSpinbox = 0 6 | audioQualitySlider = 50 7 | containerComboBox = mp4 8 | customCommandTextEdit = 9 | fileSizeSpinBox = 0 10 | fileSizeUnitComboBox = Megabytes 11 | fpsSpinBox = 0 12 | heightSpinBox = 0 13 | speedSpinBox = 0 14 | videoCodecComboBox = Passthrough 15 | widthSpinBox = 0 16 | 17 | [Discord] 18 | aspectRatioSpinBoxH = 0 19 | aspectRatioSpinBoxV = 0 20 | audioCodecComboBox = libopus 21 | audioChannelCountSpinbox = 0 22 | audioQualitySlider = 30 23 | containerComboBox = mp4 24 | customCommandTextEdit = 25 | fileSizeSpinBox = 8 26 | fileSizeUnitComboBox = Megabytes 27 | fpsSpinBox = 0 28 | heightSpinBox = 0 29 | speedSpinBox = 0 30 | videoCodecComboBox = h264_nvenc 31 | widthSpinBox = 0 -------------------------------------------------------------------------------- /core/utils/platform_info.cpp: -------------------------------------------------------------------------------- 1 | #include "platform_info.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | PlatformInfo::PlatformInfo() { m_isNvidia = DetectNvidia(); } 9 | 10 | bool PlatformInfo::DetectNvidia() const 11 | { 12 | QOpenGLContext context; 13 | context.create(); 14 | 15 | QOffscreenSurface surface; 16 | surface.setFormat(context.format()); 17 | surface.create(); 18 | context.makeCurrent(&surface); 19 | 20 | QOpenGLFunctions functions; 21 | functions.initializeOpenGLFunctions(); 22 | 23 | const GLubyte* vendor = functions.glGetString(GL_VENDOR); 24 | const QString vendorString 25 | = QString::fromUtf8(reinterpret_cast(vendor)); 26 | 27 | return vendorString.contains("NVIDIA", Qt::CaseInsensitive); 28 | } 29 | -------------------------------------------------------------------------------- /core/notifier/message.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MESSAGE_H 2 | #define MESSAGE_H 3 | 4 | #include 5 | #include 6 | 7 | enum Severity { 8 | Info = QMessageBox::Information, 9 | Warning = QMessageBox::Warning, 10 | Error = QMessageBox::Critical, 11 | Critical // should terminate program 12 | }; 13 | 14 | //! 15 | //! \brief Represents a message to be displayed to the user. 16 | //! 17 | struct Message { 18 | public: 19 | Message(Severity severity, QString title, QString message, QString details = "", bool isLikelyBug = false) 20 | : severity(severity) 21 | , title(std::move(title)) 22 | , message(std::move(message)) 23 | , details(std::move(details)) 24 | , isLikelyBug(isLikelyBug) 25 | { 26 | } 27 | 28 | const Severity severity; 29 | const QString title; 30 | const QString message; 31 | const QString details; 32 | const bool isLikelyBug; 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /core/encoder/encoder_options.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ENCODER_OPTIONS_H 2 | #define ENCODER_OPTIONS_H 3 | 4 | #include 5 | #include 6 | 7 | #include "core/formats/codec.hpp" 8 | #include "core/formats/container.hpp" 9 | #include "core/formats/metadata.hpp" 10 | 11 | using std::optional; 12 | 13 | struct EncoderOptions 14 | { 15 | const Metadata inputMetadata; 16 | const QString inputPath; 17 | const QString outputPath; 18 | const optional videoCodec; 19 | const optional audioCodec; 20 | const Container container; 21 | const optional sizeKbps; 22 | const optional audioQualityPercent; 23 | const optional audioChannelsCount; 24 | const optional outputWidth; 25 | const optional outputHeight; 26 | const optional aspectRatio; 27 | const optional fps; 28 | const optional speed; 29 | const double minVideoBitrateKbps = 64; 30 | const double minAudioBitrateKbps = 16; 31 | const double maxAudioBitrateKbps = 256; 32 | const double overshootCorrectionPercent = 0.02; 33 | const optional customArguments; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /core/formats/ffmpeg_format_support_loader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FFMPEG_FORMAT_SUPPORT_LOADER_H 2 | #define FFMPEG_FORMAT_SUPPORT_LOADER_H 3 | 4 | #include "format_support.hpp" 5 | #include "format_support_loader.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class FFmpegFormatSupportLoader : public FormatSupportLoader 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | FFmpegFormatSupportLoader(); 18 | 19 | void QuerySupportedFormatsAsync() override; 20 | 21 | private slots: 22 | void onCodecsQueried(); 23 | void onContainersQueried(); 24 | 25 | private: 26 | QPair, QList> parseCodecs(); 27 | QList parseContainers(); 28 | bool EnsureValidResult(QProcess* process); 29 | void SkipLines(size_t count) const; 30 | void CheckQueryComplete(); 31 | 32 | QProcess* codecsProcess; 33 | QProcess* containersProcess; 34 | bool codecsQueried = false; 35 | bool containersQueried = false; 36 | QMetaObject::Connection connection; 37 | QSharedPointer cachedFormats; 38 | 39 | QPair, QList> codecs; 40 | QList containers; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /core/notifier/message_box_notifier.cpp: -------------------------------------------------------------------------------- 1 | #include "message_box_notifier.hpp" 2 | 3 | #include 4 | 5 | void MessageBoxNotifier::Notify(const Message& message) const 6 | { 7 | if (message.isLikelyBug || message.severity == Severity::Critical) 8 | Notify(message.severity, message.title, message.message + bugReportPrompt, message.details); 9 | else 10 | Notify(message.severity, message.title, message.message, message.details); 11 | } 12 | 13 | void MessageBoxNotifier::Notify(Severity severity, const QString& title, const QString& message, const QString& details) const 14 | { 15 | QFont font; 16 | font.setBold(true); 17 | 18 | QMessageBox dialog; 19 | dialog.setWindowTitle(QApplication::applicationName()); 20 | dialog.setIcon(severity == Severity::Critical ? QMessageBox::Critical : (QMessageBox::Icon)severity); 21 | dialog.setText("" + title + "."); 22 | dialog.setInformativeText(message); 23 | dialog.setDetailedText(details); 24 | dialog.setStandardButtons(QMessageBox::Ok); 25 | dialog.exec(); 26 | 27 | // wait until event loop has begun before attempting to exit 28 | if (severity == Severity::Critical) 29 | QMetaObject::invokeMethod(QApplication::instance(), "exit", Qt::QueuedConnection); 30 | } 31 | -------------------------------------------------------------------------------- /core/settings/ini_settings.cpp: -------------------------------------------------------------------------------- 1 | #include "ini_settings.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | IniSettings::IniSettings(const QString& fileName, const QString& defaultFileName) 8 | { 9 | if (const QFile file(defaultFileName); file.exists()) { 10 | defaultSettings = new QSettings(defaultFileName, QSettings::IniFormat); 11 | } 12 | 13 | settings = new QSettings(fileName, QSettings::IniFormat); 14 | } 15 | 16 | QVariant IniSettings::get(const QString& key) const 17 | { 18 | if (settings->contains(key)) 19 | return settings->value(key); 20 | 21 | if (!defaultSettings.isNull() && defaultSettings->contains(key)) 22 | return defaultSettings->value(key); 23 | 24 | return {}; 25 | } 26 | 27 | QStringList IniSettings::keysInGroup(const QString& group) const 28 | { 29 | settings->beginGroup(group); 30 | QStringList keys = settings->childKeys(); 31 | settings->endGroup(); 32 | 33 | return keys; 34 | } 35 | 36 | QString IniSettings::fileName() const 37 | { 38 | return settings->fileName(); 39 | } 40 | 41 | void IniSettings::Set(const QString& key, const QVariant& value) 42 | { 43 | settings->setValue(key, value); 44 | } 45 | 46 | QStringList IniSettings::groups() const 47 | { 48 | return settings->childGroups(); 49 | } 50 | -------------------------------------------------------------------------------- /core/main.cpp: -------------------------------------------------------------------------------- 1 | #include "encoder/encoder.hpp" 2 | #include "formats/ffmpeg_format_support_loader.hpp" 3 | #include "mainwindow.hpp" 4 | #include "notifier/message_box_notifier.hpp" 5 | #include "settings/ini_settings.hpp" 6 | #include "settings/serializer.hpp" 7 | #include "thirdparty/boost-di/di.hpp" 8 | 9 | namespace di = boost::di; 10 | 11 | #include 12 | 13 | int main(int argc, char* argv[]) 14 | { 15 | QApplication app(argc, argv); 16 | app.setApplicationName("Simple Media Encoder"); 17 | app.setStyle("Fusion"); 18 | 19 | QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, QDir::current().absolutePath()); 20 | 21 | const auto injector = make_injector( 22 | di::bind.named(di_settings).to([] 23 | { return std::make_shared("config.ini", "config_default.ini"); }), 24 | di::bind.named(di_presets).to([] 25 | { return std::make_shared("presets.ini"); }), 26 | di::bind.to(), di::bind.to() 27 | ); 28 | 29 | const auto w = injector.create>(); 30 | w->setWindowIcon(QIcon("appicon.ico")); 31 | w->show(); 32 | 33 | return app.exec(); 34 | } 35 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Dev environment for simple-media-encoder"; 3 | 4 | inputs.flake-utils.url = "github:numtide/flake-utils"; 5 | 6 | outputs = { self, flake-utils, nixpkgs }: 7 | flake-utils.lib.eachDefaultSystem (system: let 8 | pkgs = import nixpkgs { 9 | inherit system; 10 | }; 11 | in { 12 | packages = rec { 13 | SimpleMediaEncoder = pkgs.qt6Packages.callPackage ./build.nix {}; 14 | default = SimpleMediaEncoder; 15 | }; 16 | devShell = 17 | pkgs.mkShell { 18 | inputsFrom = [ 19 | self.packages.${system}.default 20 | ]; 21 | buildInputs = with pkgs; [ 22 | lldb 23 | clang 24 | cmake 25 | 26 | # LSPs for Emacs or Neovim 27 | python3Minimal 28 | cmake-language-server 29 | clang-tools 30 | 31 | qt6.wrapQtAppsHook 32 | qt6.qtbase 33 | makeWrapper 34 | 35 | # runtime deps 36 | ffmpeg 37 | ]; 38 | shellHook = '' 39 | fishdir=$(mktemp -d) 40 | makeWrapper "$(type -p fish)" "$fishdir/fish" "''${qtWrapperArgs[@]}" 41 | 42 | export CXX="clang++" 43 | export CC="clang" 44 | 45 | exec "$fishdir/fish" 46 | ''; 47 | }; 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /core/settings/serializer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "settings.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /*! 10 | * \brief Provides a unified way to serialize and deserialize widgets from/to a data source. 11 | * \details For some reason, Qt's input widgets don't implement a common interface for getting and setting their values. This class abstracts widget state persistence. 12 | * \remark Throughout the class, QObject is used instead of QWidget because QButtonGroup inherits the former. It will fail at runtime if a widget's type is not supported. 13 | */ 14 | class Serializer 15 | { 16 | public: 17 | void serialize(const QObject* widget, const std::shared_ptr& dataSource, const QString& dataSourceKey) const; 18 | void deserialize(QObject* widget, const std::shared_ptr& dataSource, const QString& dataSourceKey) const; 19 | 20 | void serializeMany(const QList& widgets, const std::shared_ptr& dataSource, const QString& dataSourceKey) const; 21 | void deserializeMany(const QList& widgets, const std::shared_ptr& dataSource, const QString& dataSourceKey) const; 22 | 23 | private: 24 | QString getKey(const QObject* widget, const QString& dataSourceKey) const; 25 | QVariant getWidgetValue(const QObject* widget) const; 26 | void setWidgetValue(QObject* widget, const QVariant& value) const; 27 | }; 28 | -------------------------------------------------------------------------------- /bin/config_default.ini: -------------------------------------------------------------------------------- 1 | # Default configuration. Do not modify. Overriden by any corresponding key in config.ini. 2 | 3 | [Main] 4 | dMaxBitrateAudioKbps = 256 5 | dMinBitrateAudioKbps = 16 6 | dMinBitrateVideoKbps = 64 7 | iProgressBarAnimDurationMs = 175 8 | iProgressWidgetAnimDurationMs = 300 9 | iSectionAnimDurationMs = 250 10 | 11 | [FormatSelection] 12 | sCommonVideoCodecs = libaom-av1,av1_nvenc,av1_qsv,av1_amf,gif,libx264,libx264rgb,h264_amf,h264_mf,h264_nvenc,h264_qsv,libx265,hevc_amf,hevc_mf,hevc_nvenc,hevc_qsv,libwebp_anim,libvpx-vp9,vp9_qsv 13 | sCommonAudioCodecs = aac,aac_mf,flac,libmp3lame,mp3_mf,libopus,libvorbis 14 | sCommonContainers = avi,flac,gif,matroska,mov,mp3,mp4,ogg,opus,webm 15 | 16 | [Preferences] 17 | advancedModeCheckBox = false 18 | audioVideoButtonGroup = 0 19 | autoFillCheckBox = false 20 | closeOnSuccessCheckBox = false 21 | commonFormatsOnlyCheckbox = true 22 | deleteOnSuccessCheckBox = false 23 | inputFileLineEdit = 24 | openExplorerOnSuccessCheckBox = false 25 | outputFileNameLineEdit = compressed 26 | outputFileNameSuffixCheckBox = true 27 | outputFolderLineEdit = 28 | playOnSuccessCheckBox = true 29 | qualityPresetComboBox = None 30 | warnOnOverwriteCheckBox = false 31 | 32 | [PreviousSettings] 33 | aspectRatioSpinBoxH = 0 34 | aspectRatioSpinBoxV = 0 35 | audioChannelCountSpinbox = 0 36 | audioCodecComboBox = aac 37 | audioQualitySlider = 50 38 | containerComboBox = mp4 39 | customCommandTextEdit = 40 | fileSizeSpinBox = 0 41 | fileSizeUnitComboBox = Megabytes 42 | fpsSpinBox = 0 43 | heightSpinBox = 0 44 | speedSpinBox = 0 45 | videoCodecComboBox = h264_nvenc 46 | widthSpinBox = 0 47 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "flake-utils": { 4 | "inputs": { 5 | "systems": "systems" 6 | }, 7 | "locked": { 8 | "lastModified": 1731533236, 9 | "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", 10 | "owner": "numtide", 11 | "repo": "flake-utils", 12 | "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", 13 | "type": "github" 14 | }, 15 | "original": { 16 | "owner": "numtide", 17 | "repo": "flake-utils", 18 | "type": "github" 19 | } 20 | }, 21 | "nixpkgs": { 22 | "locked": { 23 | "lastModified": 0, 24 | "narHash": "sha256-dlK7n82FEyZlHH7BFHQAM5tua+lQO1Iv7aAtglc1O5s=", 25 | "path": "/nix/store/p171b66grkl59wsxsf5v06q9kkllajxf-source", 26 | "type": "path" 27 | }, 28 | "original": { 29 | "id": "nixpkgs", 30 | "type": "indirect" 31 | } 32 | }, 33 | "root": { 34 | "inputs": { 35 | "flake-utils": "flake-utils", 36 | "nixpkgs": "nixpkgs" 37 | } 38 | }, 39 | "systems": { 40 | "locked": { 41 | "lastModified": 1681028828, 42 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 43 | "owner": "nix-systems", 44 | "repo": "default", 45 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 46 | "type": "github" 47 | }, 48 | "original": { 49 | "owner": "nix-systems", 50 | "repo": "default", 51 | "type": "github" 52 | } 53 | } 54 | }, 55 | "root": "root", 56 | "version": 7 57 | } 58 | -------------------------------------------------------------------------------- /core/formats/metadata_loader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef METADATA_LOADER_H 2 | #define METADATA_LOADER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "metadata.hpp" 11 | #include "core/notifier/message.hpp" 12 | #include "core/utils/platform_info.hpp" 13 | 14 | typedef std::variant MetadataResult; 15 | 16 | class MetadataLoader : public QObject 17 | { 18 | Q_OBJECT 19 | public: 20 | MetadataLoader(const PlatformInfo& platformInfo); 21 | 22 | void loadAsync(const QString& path); 23 | 24 | signals: 25 | void loadAsyncComplete(MetadataResult result); 26 | 27 | private: 28 | void handleResult(); 29 | MetadataResult parse(QByteArray data); 30 | 31 | double getFrameRate(QList& errors); 32 | std::pair getAspectRatio(QList& errors); 33 | 34 | inline QVariant value(QList& errors, QJsonObject& source, const QString& key, bool required = false) 35 | { 36 | if (source.isEmpty()) 37 | return {}; 38 | 39 | if (source.contains(key)) 40 | return source.value(key).toVariant(); 41 | 42 | if (required) 43 | NotFound(errors, key); 44 | 45 | return {}; 46 | } 47 | 48 | inline void NotFound(QList& errors, const QString& key) const 49 | { 50 | errors.append(QString("Could not find %1 in metadata.").arg(key)); 51 | } 52 | 53 | QProcess ffprobe; 54 | PlatformInfo platform; 55 | 56 | QJsonObject format; 57 | QJsonObject video; 58 | QJsonObject audio; 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /core/encoder/encoder_options_builder.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ENCODER_OPTIONS_BUILDER_H 2 | #define ENCODER_OPTIONS_BUILDER_H 3 | 4 | #include "core/formats/codec.hpp" 5 | #include "core/formats/container.hpp" 6 | #include "core/formats/metadata.hpp" 7 | #include "encoder_options.hpp" 8 | 9 | using std::optional; 10 | 11 | class EncoderOptionsBuilder 12 | { 13 | typedef EncoderOptionsBuilder self; 14 | 15 | public: 16 | self& useMetadata(const Metadata& metadata); 17 | self& inputFrom(const QString& inputPath); 18 | self& outputTo(const QString& outputPath); 19 | self& withVideoCodec(const Codec& codec); 20 | self& withAudioCodec(const Codec& codec); 21 | self& withContainer(const Container& container); 22 | self& withTargetOutputSize(double sizeKbps); 23 | self& withAudioQuality(double audioQualityPercent); 24 | self& withAudioChannelsCount(int audioChannelsCount); 25 | self& withOutputWidth(int outputWidth); 26 | self& withOutputHeight(int outputHeight); 27 | self& withAspectRatio(const QPoint& aspectRatio); 28 | self& atFps(int fps); 29 | self& atSpeed(double speed); 30 | self& withMinVideoBitrate(double bitrateKbps); 31 | self& withMinAudioBitrate(double bitrateKbps); 32 | self& withMaxAudioBitrate(double bitrateKbps); 33 | self& withOvershootCorrection(double overshootCorrectionPercent); 34 | self& withCustomArguments(const QString& customArguments); 35 | 36 | std::variant> build(); 37 | 38 | private: 39 | optional inputMetadata; 40 | optional inputPath; 41 | optional outputPath; 42 | optional videoCodec; 43 | optional audioCodec; 44 | optional container; 45 | optional sizeKbps; 46 | optional audioQualityPercent; 47 | optional audioChannelsCount; 48 | optional outputWidth; 49 | optional outputHeight; 50 | optional aspectRatio; 51 | optional fps; 52 | optional speed; 53 | double minVideoBitrateKbps = 64; 54 | double minAudioBitrateKbps = 16; 55 | double maxAudioBitrateKbps = 256; 56 | double overshootCorrectionPercent = 0.02; 57 | optional customArguments; 58 | 59 | QList errors; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /ui/overlay_widget.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /*! 9 | * \brief A widget that displays a semi-transparent overlay with centered text. 10 | */ 11 | class OverlayWidget final : public QWidget 12 | { 13 | public: 14 | explicit OverlayWidget(QWidget* parent = nullptr) 15 | : QWidget(parent) 16 | , text("") 17 | { 18 | setAttribute(Qt::WA_TransparentForMouseEvents); 19 | setAttribute(Qt::WA_NoSystemBackground); 20 | setAttribute(Qt::WA_TranslucentBackground); 21 | 22 | opacityEffect = new QGraphicsOpacityEffect(this); 23 | setGraphicsEffect(opacityEffect); 24 | 25 | fadeAnimation = new QPropertyAnimation(opacityEffect, "opacity", this); 26 | fadeAnimation->setDuration(300); 27 | } 28 | 29 | void setText(const QString& text) 30 | { 31 | this->text = text; 32 | update(); 33 | } 34 | 35 | void setBackgroundColor(const QColor& color) 36 | { 37 | this->backgroundColor = color; 38 | update(); 39 | } 40 | 41 | void showWithFade() 42 | { 43 | show(); 44 | fadeAnimation->setStartValue(0.0); 45 | fadeAnimation->setEndValue(1.0); 46 | disconnect(onFadeOutFinished); 47 | fadeAnimation->start(); 48 | } 49 | 50 | void hideWithFade() 51 | { 52 | fadeAnimation->setStartValue(1.0); 53 | fadeAnimation->setEndValue(0.0); 54 | disconnect(onFadeOutFinished); 55 | onFadeOutFinished = connect(fadeAnimation, &QPropertyAnimation::finished, this, &OverlayWidget::hide); 56 | fadeAnimation->start(); 57 | } 58 | 59 | protected: 60 | void paintEvent(QPaintEvent* event) override 61 | { 62 | QPainter painter(this); 63 | painter.fillRect(rect(), backgroundColor); 64 | 65 | QFont font = painter.font(); 66 | font.setPointSize(32); 67 | painter.setPen(Qt::white); 68 | painter.setFont(font); 69 | 70 | const QRect textRect = painter.boundingRect(rect(), Qt::AlignCenter, text); 71 | painter.drawText(textRect, Qt::AlignCenter, text); 72 | } 73 | 74 | private: 75 | QString text; 76 | QColor backgroundColor; 77 | QGraphicsOpacityEffect* opacityEffect; 78 | QPropertyAnimation* fadeAnimation; 79 | 80 | QMetaObject::Connection onFadeOutFinished; 81 | }; -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(SimpleMediaEncoder VERSION 1.0 LANGUAGES CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 23) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wextra -Wno-unused-parameter") 8 | set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_SOURCE_DIR}/ui) 9 | set(BOOST_DI_CFG_DIAGNOSTICS_LEVEL 2) 10 | add_definitions(-DQT_DISABLE_DEPRECATED_UP_TO=0x060700) 11 | 12 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 13 | set(CMAKE_THREAD_LIBS_INIT "-lpthread") 14 | endif () 15 | 16 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 17 | 18 | find_package(Qt6 REQUIRED COMPONENTS Widgets) 19 | qt_standard_project_setup() 20 | 21 | include_directories(${CMAKE_SOURCE_DIR}) 22 | 23 | set(SOURCES 24 | core/main.cpp 25 | core/mainwindow.hpp 26 | core/mainwindow.cpp 27 | core/encoder/encoder.hpp 28 | core/encoder/encoder.cpp 29 | core/encoder/encoder_options.hpp 30 | core/encoder/encoder_options_builder.cpp 31 | core/encoder/encoder_options_builder.hpp 32 | core/formats/codec.hpp 33 | core/formats/container.hpp 34 | core/formats/ffmpeg_format_support_loader.hpp 35 | core/formats/ffmpeg_format_support_loader.cpp 36 | core/formats/format_support.hpp 37 | core/formats/format_support_loader.hpp 38 | core/formats/metadata.hpp 39 | core/formats/metadata_loader.hpp 40 | core/formats/metadata_loader.cpp 41 | core/notifier/message.hpp 42 | core/notifier/message_box_notifier.hpp 43 | core/notifier/message_box_notifier.cpp 44 | core/notifier/notifier.hpp 45 | core/settings/ini_settings.hpp 46 | core/settings/ini_settings.cpp 47 | core/settings/serializer.hpp 48 | core/settings/serializer.cpp 49 | core/settings/settings.hpp 50 | core/utils/platform_info.hpp 51 | core/utils/platform_info.cpp 52 | core/utils/warnings.hpp 53 | core/utils/warnings.cpp 54 | ui/overlay_widget.cpp 55 | ui/overlay_widget.hpp 56 | ) 57 | 58 | set(RESOURCES 59 | ui/mainwindow.ui 60 | bin/appicon.ico 61 | bin/config_default.ini 62 | ) 63 | 64 | add_library(boost-di INTERFACE) 65 | target_include_directories(boost-di INTERFACE ${CMAKE_SOURCE_DIR}/thirdparty/boost-di) 66 | 67 | qt_add_executable(${PROJECT_NAME} ${SOURCES} ${RESOURCES}) 68 | 69 | target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets boost-di) 70 | 71 | set_target_properties(${PROJECT_NAME} PROPERTIES 72 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin 73 | WIN32_EXECUTABLE ON 74 | MACOSX_BUNDLE ON 75 | ) 76 | -------------------------------------------------------------------------------- /core/encoder/encoder.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MEDIAENCODER_H 2 | #define MEDIAENCODER_H 3 | 4 | #include "core/formats/codec.hpp" 5 | #include "core/formats/container.hpp" 6 | #include "core/formats/metadata.hpp" 7 | #include "encoder_options.hpp" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | struct Message; 17 | using std::optional; 18 | 19 | class MediaEncoder final : public QObject 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit MediaEncoder(); 25 | 26 | struct ComputedOptions 27 | { 28 | optional videoBitrateKbps; 29 | optional audioBitrateKbps; 30 | }; 31 | 32 | void Encode(const EncoderOptions& options); 33 | QString getAvailableFormats() const; 34 | 35 | signals: 36 | void encodingStarted(double videoBitrateKbps, double audioBitrateKbps); 37 | void encodingSucceeded(const EncoderOptions& options, const ComputedOptions& computed, QFile& output); 38 | void encodingProgressUpdate(double progressPercent); 39 | void encodingFailed(QString error, QString errorDetails = ""); 40 | 41 | private: 42 | const bool IS_WINDOWS = QSysInfo::kernelType() == "winnt"; 43 | 44 | void StartCompression(const EncoderOptions& options, const ComputedOptions& computedOptions, const Metadata& metadata); 45 | void UpdateProgress(double mediaDuration); 46 | void EndCompression( 47 | const EncoderOptions& options, const ComputedOptions& computed, QString outputPath, QString command, int exitCode 48 | ); 49 | 50 | [[nodiscard]] QString BuildBaseParams(const EncoderOptions& options, const ComputedOptions& computed) const; 51 | [[nodiscard]] QString BuildVideoFilterParams(const EncoderOptions& options, [[maybe_unused]] const ComputedOptions& computed) const; 52 | [[nodiscard]] QString BuildAudioFilterParams(const EncoderOptions& options, const ComputedOptions& computed) const; 53 | 54 | void ComputeVideoBitrate(const EncoderOptions& options, ComputedOptions& computed, const Metadata& metadata) const; 55 | bool computeAudioBitrate(const EncoderOptions& options, ComputedOptions& computed) const; 56 | double computePixelRatio(const EncoderOptions& options, const Metadata& metadata) const; 57 | 58 | std::variant extensionForContainer(const Container& container) const; 59 | 60 | QString output = ""; 61 | QString parseOutput() const; 62 | 63 | QEventLoop eventLoop; 64 | QProcess* ffmpeg = new QProcess(&eventLoop); 65 | 66 | QMetaObject::Connection processUpdateConnection; 67 | QMetaObject::Connection processFinishedConnection; 68 | }; 69 | 70 | #endif // MEDIAENCODER_H 71 | -------------------------------------------------------------------------------- /core/formats/ffmpeg_format_support_loader.cpp: -------------------------------------------------------------------------------- 1 | #include "ffmpeg_format_support_loader.hpp" 2 | #include "codec.hpp" 3 | #include "core/notifier/notifier.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | FFmpegFormatSupportLoader::FFmpegFormatSupportLoader() 10 | : codecsProcess(new QProcess(this)) 11 | , containersProcess(new QProcess(this)) { } 12 | 13 | void FFmpegFormatSupportLoader::QuerySupportedFormatsAsync() 14 | { 15 | if (cachedFormats != nullptr) { 16 | emit queryCompleted(cachedFormats); 17 | return; 18 | } 19 | 20 | connect(codecsProcess, &QProcess::finished, this, &FFmpegFormatSupportLoader::onCodecsQueried); 21 | codecsProcess->startCommand(R"(ffmpeg -encoders -hide_banner)"); 22 | 23 | connect(containersProcess, &QProcess::finished, this, &FFmpegFormatSupportLoader::onContainersQueried); 24 | containersProcess->startCommand(R"(ffmpeg -muxers -hide_banner)"); 25 | } 26 | 27 | void FFmpegFormatSupportLoader::onCodecsQueried() 28 | { 29 | codecs = parseCodecs(); 30 | codecsQueried = true; 31 | 32 | CheckQueryComplete(); 33 | } 34 | 35 | void FFmpegFormatSupportLoader::onContainersQueried() 36 | { 37 | containers = parseContainers(); 38 | containersQueried = true; 39 | 40 | CheckQueryComplete(); 41 | } 42 | 43 | QPair, QList> FFmpegFormatSupportLoader::parseCodecs() 44 | { 45 | if (!EnsureValidResult(codecsProcess)) 46 | return {}; 47 | 48 | QList videoCodecs; 49 | QList audioCodecs; 50 | 51 | SkipLines(10); 52 | 53 | while (codecsProcess->canReadLine()) { 54 | QString line = codecsProcess->readLine().trimmed(); 55 | bool isAudio; 56 | 57 | // TODO: Audio boolean member might be unnecessary 58 | if (line[0] == 'V') 59 | isAudio = false; 60 | else if (line[0] == 'A') 61 | isAudio = true; 62 | else 63 | continue; 64 | 65 | static QRegularExpression delimiter("\\s"); 66 | const QString libraryName = line.section(delimiter, 1, 2).trimmed(); 67 | const QString displayName = line.section(delimiter, 2).trimmed(); 68 | 69 | Codec codec { displayName, libraryName, isAudio }; 70 | 71 | if (isAudio) 72 | audioCodecs.append(codec); 73 | else 74 | videoCodecs.append(codec); 75 | } 76 | 77 | return { videoCodecs, audioCodecs }; 78 | } 79 | 80 | QList FFmpegFormatSupportLoader::parseContainers() 81 | { 82 | if (!EnsureValidResult(containersProcess)) 83 | return {}; 84 | 85 | QList containers; 86 | 87 | while (containersProcess->canReadLine()) { 88 | QString line = containersProcess->readLine().trimmed(); 89 | 90 | if (line[0] != 'E') 91 | continue; 92 | 93 | static QRegularExpression delimiter("\\s"); 94 | const QString libraryName = line.section(delimiter, 1, 2).trimmed(); 95 | const QString displayName = line.section(delimiter, 2).trimmed(); 96 | 97 | containers.append({ displayName, libraryName }); 98 | } 99 | 100 | return containers; 101 | } 102 | 103 | bool FFmpegFormatSupportLoader::EnsureValidResult(QProcess* process) 104 | { 105 | if (process->exitStatus() == QProcess::CrashExit || process->exitCode() != 0) { 106 | emit queryCompleted(Message( 107 | Severity::Critical, 108 | QObject::tr("Failed to query supported formats"), 109 | QObject::tr("Asking FFmpeg for available encoders failed because: '%1'.").arg(process->errorString()), 110 | process->readAllStandardError() 111 | )); 112 | 113 | return false; 114 | } 115 | 116 | return true; 117 | } 118 | 119 | void FFmpegFormatSupportLoader::SkipLines(size_t count) const 120 | { 121 | for (size_t i = 0; i < count; i++) { 122 | codecsProcess->readLine(); 123 | } 124 | } 125 | 126 | void FFmpegFormatSupportLoader::CheckQueryComplete() 127 | { 128 | if (codecsQueried && containersQueried) { 129 | cachedFormats = QSharedPointer::create(codecs.first, codecs.second, containers); 130 | emit queryCompleted(cachedFormats); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple Media Encoder 2 | 3 | Compress and convert your media files in a breeze with this convenient tool! Perfect for sending to Discord or 4 | Messenger, or reducing the size of music to listen on the go. Uses FFmpeg and Qt Widgets under GPL v3. 5 | 6 |
7 | 8 | 9 |
10 |
11 | 12 | The default interface allows anyone to quickly re-encode media files. 13 | The so-called "expert" interface gives advanced users a bit more control over the exported result. 14 | 15 | ## Compatibility 16 | 17 | - Tested on Windows 11, Windows 10, and Ubuntu. Earlier versions of Windows are not supported. 18 | - Should work on Mac as well. Let me know if you encounter issues! More testing is underway. 19 | 20 | ## Features 21 | 22 | With this tool, one may: 23 | 24 | - Re-encode **any file type** supported by FFmpeg; 25 | - Choose whether to export **video, audio, or both**; 26 | - Quickly select a **quality preset**, or manually tune **your settings**; 27 | - Choose **audio bitrate**; 28 | - **Re-scale video** with automatic aspect ratio adjustment, or manually adjust the **aspect ratio**; 29 | - Change the **video and audio speed** or manually set a video framerate; 30 | - Specify **custom FFmpeg arguments** for advanced use. 31 | 32 | Furthermore, one may: 33 | 34 | - Choose to **auto-fill** all fields when a file is selected; 35 | - **Delete** the input file on success; 36 | - Decide whether to **warn** when a file is about to be overwritten; 37 | - Specify the **output name** as a file name or as a suffix to the input name; 38 | - View **detailed statistics** about your media file *(to be implemented)*. 39 | 40 | As well as customize behavior on successful re-encoding: 41 | 42 | - Open the resulting media in the **file explorer**; 43 | - View the resulting media in the **default media player**; 44 | - **Auto-close the utility** for a one-shot export. 45 | 46 | Conveniently, all these parameters are **saved** when the tool is closed. 47 | 48 | ## How to install 49 | 50 | ### Binaries 51 | 52 | A [binary release](https://github.com/Thurinum/simple-media-encoder/releases) is available for Windows! 53 | 54 | ### Source 55 | 56 | This tool uses the Qt for Application Development framework, under the GNU GPL v3 open source license. 57 | It must be installed for compiling SME. 58 | 59 | #### On Windows 60 | 61 | 1. If Qt is not already installed on your system: 62 | - Download the Qt Open Source installer [here](https://www.qt.io/download-qt-installer) for easy setup of the 63 | framework; 64 | - Proceed with the installation of Qt (you will need a free Qt developer account): 65 | - Ideally, select version >= 6.7. 66 | - Under "Developer and Designer tools", select the latest MinGW compiler. 67 | - Compilation has been tested with the CLion and Qt Creator IDEs. 68 |

69 | 2. If FFmpeg is not already installed and in your PATH: 70 | - You must manually download and install the ffmpeg.exe and ffprobe.exe binaries. 71 | - You may find links to mirrors [here](https://ffmpeg.org/download.html#build-windows). 72 | - Extract the archive and place the two binaries (and associated libraries if present) inside the `bin` 73 | directory (or add them to your PATH). 74 | 3. Build the project: 75 | - Run the cmake project in your IDE (tested with CLion and Qt Creator). 76 | 77 | #### On Linux (with apt) 78 | 79 | ```bash 80 | sudo apt update -y 81 | sudo apt upgrade -y 82 | sudo apt install git build-essential cmake qt6-base-dev qt6-base-dev-tools -y 83 | 84 | git clone https://github.com/Thurinum/simple-media-encoder.git 85 | cd simple-media-encoder 86 | 87 | cmake . 88 | make 89 | bin/SimpleMediaEncoder 90 | ``` 91 | 92 | ## Technologies used 93 | 94 | - ffmpeg and ffprobe 95 | - The Qt framework (Qt Widgets) 96 | 97 | ## Special thanks to 98 | 99 | Theodore l'Heureux (for his consulting and beta-testing) 100 | William Boulanger (for his advice and knowledge on audio theory) 101 | 102 | ## Found an issue? 103 | 104 | This is a beta, and the tool may face difficulties opening certain files. 105 | Should you encounter such a problematic file, feel free to file a Github issue; it will help finding the problem. 106 | Any bug reports are also greatly appreciated! 107 | 108 | Thanks for reading through this and cheers! 109 | -------------------------------------------------------------------------------- /core/mainwindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/formats/metadata_loader.hpp" 4 | #include "encoder/encoder.hpp" 5 | #include "formats/format_support_loader.hpp" 6 | #include "notifier/notifier.hpp" 7 | #include "settings/serializer.hpp" 8 | #include "settings/settings.hpp" 9 | #include "ui/overlay_widget.hpp" 10 | #include "utils/platform_info.hpp" 11 | #include "utils/warnings.hpp" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | QT_BEGIN_NAMESPACE 21 | namespace Ui 22 | { 23 | class MainWindow; 24 | } 25 | QT_END_NAMESPACE 26 | 27 | inline auto di_settings = [] {}; 28 | inline auto di_presets = [] {}; 29 | 30 | class MainWindow final : public QMainWindow 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | BOOST_DI_INJECT( 36 | MainWindow, 37 | MediaEncoder& encoder, 38 | (named = di_settings) std::shared_ptr settings, 39 | (named = di_presets) std::shared_ptr presetsSettings, 40 | std::shared_ptr serializer, 41 | MetadataLoader& metadata, 42 | Notifier& notifier, 43 | PlatformInfo& platformInfo, 44 | FormatSupportLoader& formatSupportLoader 45 | ); 46 | ~MainWindow() override; 47 | 48 | enum StreamType 49 | { 50 | VideoAudio, 51 | VideoOnly, 52 | AudioOnly 53 | }; 54 | 55 | protected: 56 | void CheckForFFmpeg() const; 57 | void SetupMenu(); 58 | void SetupEventCallbacks(); 59 | void QuerySupportedFormatsAsync() const; 60 | 61 | void LoadState(); 62 | void LoadPresetNames() const; 63 | void SaveState() const; 64 | 65 | void dragEnterEvent(QDragEnterEvent* event) override; 66 | void dropEvent(QDropEvent* event) override; 67 | void dragLeaveEvent(QDragLeaveEvent* event) override; 68 | void resizeEvent(QResizeEvent* event) override; 69 | void closeEvent(QCloseEvent* event) override; 70 | 71 | void HandleStart(double videoBitrateKbps, double audioBitrateKbps) const; 72 | void HandleSuccess(const EncoderOptions& options, const MediaEncoder::ComputedOptions& computed, QFile& output) const; 73 | void HandleFailure(const QString& shortError, const QString& longError) const; 74 | void ShowAbout() const; 75 | 76 | // NOTE: const parameters are NOT supported by Qt slots setup from the designer! 77 | private slots: 78 | void StartEncoding(); 79 | void SetAdvancedMode(bool enabled) const; 80 | void OpenInputFile(); 81 | void SelectOutputDirectory(); 82 | void ShowMetadata(); 83 | void LoadPreset(int index) const; 84 | void SelectVideoCodec(int index) const; 85 | void SelectAudioCodec(int index) const; 86 | void UpdateControlsState() const; 87 | void CheckAspectRatioConflict() const; 88 | void CheckSpeedConflict() const; 89 | void UpdateAudioQualityLabel(int value) const; 90 | void SetAllowPresetSelection(bool allowed) const; 91 | void HandleFormatsQueryResult(const std::variant, Message>& maybeFormats); 92 | void UpdateCodecsList(bool commonOnly) const; 93 | 94 | private: 95 | struct ProgressState 96 | { 97 | optional status = optional(); 98 | optional progressPercent = optional(); 99 | }; 100 | 101 | void QueryMediaMetadataAsync(const QString& path); 102 | void ReceiveMediaMetadata(MetadataResult result); 103 | QString getOutputPath(QString inputFilePath) const; 104 | inline bool isAutoValue(QAbstractSpinBox* spinBox) const; 105 | void SetProgressShown(const ProgressState& state) const; 106 | void LoadSelectedUrl(); 107 | void LoadInputFile(const QUrl& url); 108 | void ValidateSelectedDir() const; 109 | void SetupAnimations(); 110 | double getOutputSizeKbps() const; 111 | 112 | Ui::MainWindow* ui; 113 | QScopedPointer overlay; 114 | QScopedPointer warnings; 115 | 116 | optional metadata; 117 | 118 | std::unique_ptr> preferenceWidgets; 119 | std::unique_ptr> presetWidgets; 120 | 121 | std::unique_ptr> videoControls; 122 | std::unique_ptr> audioControls; 123 | 124 | std::unique_ptr sectionWidthAnim; 125 | std::unique_ptr sectionHeightAnim; 126 | std::unique_ptr windowSizeAnim; 127 | std::unique_ptr progressBarValueAnim; 128 | std::unique_ptr progressBarHeightAnim; 129 | 130 | QScopedPointer menu; 131 | 132 | MediaEncoder& encoder; 133 | std::shared_ptr settings; 134 | std::shared_ptr presetsSettings; 135 | std::shared_ptr serializer; 136 | MetadataLoader& metadataLoader; 137 | Notifier& notifier; 138 | PlatformInfo& platformInfo; 139 | FormatSupportLoader& formatSupport; 140 | 141 | bool isDragging = false; 142 | bool isValidMimeForDrop = false; 143 | 144 | QSharedPointer formatSupportCache; 145 | }; 146 | -------------------------------------------------------------------------------- /core/settings/serializer.cpp: -------------------------------------------------------------------------------- 1 | #include "serializer.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class QCheckBox; 11 | void Serializer::serialize(const QObject* widget, const std::shared_ptr& dataSource, const QString& dataSourceKey) const 12 | { 13 | if (!dataSource) 14 | return; 15 | 16 | const QString key = getKey(widget, dataSourceKey); 17 | 18 | dataSource->Set(key, getWidgetValue(widget)); 19 | } 20 | 21 | void Serializer::deserialize(QObject* widget, const std::shared_ptr& dataSource, const QString& dataSourceKey) const 22 | { 23 | if (!dataSource) 24 | return; 25 | 26 | const QString key = getKey(widget, dataSourceKey); 27 | const QVariant value = dataSource->get(key); 28 | setWidgetValue(widget, value); 29 | } 30 | 31 | void Serializer::serializeMany(const QList& widgets, const std::shared_ptr& dataSource, const QString& dataSourceKey) const 32 | { 33 | for (const QObject* widget : widgets) 34 | serialize(widget, dataSource, dataSourceKey); 35 | } 36 | 37 | void Serializer::deserializeMany(const QList& widgets, const std::shared_ptr& dataSource, const QString& dataSourceKey) const 38 | { 39 | for (QObject* widget : widgets) 40 | deserialize(widget, dataSource, dataSourceKey); 41 | } 42 | 43 | QString Serializer::getKey(const QObject* widget, const QString& dataSourceKey) const 44 | { 45 | return QString("%1/%2").arg(dataSourceKey, widget->objectName()); 46 | } 47 | 48 | QVariant Serializer::getWidgetValue(const QObject* widget) const 49 | { 50 | if (const auto* comboBox = qobject_cast(widget)) 51 | return comboBox->currentText(); 52 | 53 | if (const auto* plainTextEdit = qobject_cast(widget)) 54 | return plainTextEdit->toPlainText(); 55 | 56 | if (const auto* lineEdit = qobject_cast(widget)) 57 | return lineEdit->text(); 58 | 59 | if (const auto* buttonGroup = qobject_cast(widget)) 60 | return buttonGroup->checkedId(); 61 | 62 | if (const auto* spinBox = qobject_cast(widget)) 63 | return spinBox->value(); 64 | 65 | if (const auto* doubleSpinBox = qobject_cast(widget)) 66 | return doubleSpinBox->value(); 67 | 68 | if (const auto* slider = qobject_cast(widget)) 69 | return slider->value(); 70 | 71 | if (const auto* dial = qobject_cast(widget)) 72 | return dial->value(); 73 | 74 | if (const auto* progressBar = qobject_cast(widget)) 75 | return progressBar->value(); 76 | 77 | if (const auto* checkbox = qobject_cast(widget)) 78 | return checkbox->isChecked(); 79 | 80 | if (const auto* groupBox = qobject_cast(widget)) 81 | return groupBox->isChecked(); 82 | 83 | const std::string error = std::format("Widget '{}' has unsupported type '{}' for serialization.", widget->objectName().toStdString(), widget->metaObject()->className()); 84 | throw std::runtime_error(error); 85 | } 86 | void Serializer::setWidgetValue(QObject* widget, const QVariant& value) const 87 | { 88 | if (auto* comboBox = qobject_cast(widget)) 89 | { 90 | comboBox->setCurrentText(value.toString()); 91 | } 92 | else if (auto* plainTextEdit = qobject_cast(widget)) 93 | { 94 | plainTextEdit->setPlainText(value.toString()); 95 | } 96 | else if (auto* lineEdit = qobject_cast(widget)) 97 | { 98 | lineEdit->setText(value.toString()); 99 | } 100 | else if (const auto* buttonGroup = qobject_cast(widget)) 101 | { 102 | if (QAbstractButton* checkedButton = buttonGroup->button(value.toInt())) 103 | { 104 | checkedButton->setChecked(true); 105 | } 106 | } 107 | else if (auto* spinBox = qobject_cast(widget)) 108 | { 109 | spinBox->setValue(value.toInt()); 110 | } 111 | else if (auto* doubleSpinBox = qobject_cast(widget)) 112 | { 113 | doubleSpinBox->setValue(value.toDouble()); 114 | } 115 | else if (auto* slider = qobject_cast(widget)) 116 | { 117 | slider->setValue(value.toInt()); 118 | } 119 | else if (auto* dial = qobject_cast(widget)) 120 | { 121 | dial->setValue(value.toInt()); 122 | } 123 | else if (auto* progressBar = qobject_cast(widget)) 124 | { 125 | progressBar->setValue(value.toInt()); 126 | } 127 | else if (auto* checkbox = qobject_cast(widget)) 128 | { 129 | checkbox->setChecked(value.toBool()); 130 | } 131 | else if (auto* groupBox = qobject_cast(widget)) 132 | { 133 | groupBox->setChecked(value.toBool()); 134 | } 135 | else 136 | { 137 | const std::string error = std::format("Widget '{}' has unsupported type '{}' for deserialization.", widget->objectName().toStdString(), widget->metaObject()->className()); 138 | throw std::runtime_error(error); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /core/formats/metadata_loader.cpp: -------------------------------------------------------------------------------- 1 | #include "metadata_loader.hpp" 2 | #include "core/notifier/message.hpp" 3 | #include "metadata.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | MetadataResult MetadataLoader::parse(QByteArray data) 12 | { 13 | const QJsonDocument document = QJsonDocument::fromJson(data); 14 | 15 | if (document.isNull()) 16 | { 17 | return Message( 18 | Severity::Error, 19 | QObject::tr( 20 | "Could not retrieve media metadata. Is the file corrupted?" 21 | ), 22 | QObject::tr("Found metadata: %1").arg(data) 23 | ); 24 | } 25 | 26 | const QJsonObject root = document.object(); 27 | QJsonArray streams = root.value("streams").toArray(); 28 | 29 | // we only support 1 stream of each type at the moment 30 | format = root.value("format").toObject(); 31 | bool isAudio = false; 32 | 33 | for (QJsonValueRef streamRef : streams) 34 | { 35 | QJsonObject stream = streamRef.toObject(); 36 | QJsonValue type = stream.value("codec_type"); 37 | 38 | if (type == "video" && video.isEmpty()) 39 | { 40 | video = stream; 41 | } 42 | 43 | if (type == "audio" && audio.isEmpty()) 44 | { 45 | audio = stream; 46 | isAudio = true; 47 | } 48 | } 49 | 50 | if (format.isEmpty() || (video.isEmpty() && audio.isEmpty())) 51 | { 52 | return Message( 53 | Severity::Error, 54 | QObject::tr("Media metadata is incomplete."), 55 | QObject::tr("Found metadata: %1").arg(data) 56 | ); 57 | } 58 | 59 | Metadata metadata; 60 | QList errors; 61 | const std::pair aspectRatio = getAspectRatio(errors); 62 | 63 | metadata = Metadata { 64 | .width = value(errors, video, "width", true).toDouble(), 65 | .height = value(errors, video, "height", true).toDouble(), 66 | .sizeKbps = value(errors, format, "size", true).toDouble() * 0.001, 67 | .audioBitrateKbps = value(errors, audio, "bit_rate").toDouble() * 0.001, 68 | .durationSeconds = value(errors, format, "duration", true).toDouble(), 69 | .aspectRatioX = aspectRatio.first, 70 | .aspectRatioY = aspectRatio.second, 71 | .frameRate = isAudio ? 0 : getFrameRate(errors), 72 | .videoCodec = value(errors, video, "codec_name", true).toString(), 73 | .audioCodec = value(errors, audio, "codec_name", true).toString(), 74 | .container = "" // TODO: Find a reliable way to query format type 75 | }; 76 | 77 | if (!errors.isEmpty()) 78 | { 79 | return Message( 80 | Severity::Error, 81 | "Missing metadata fields", 82 | "The following metadata fields could not be found: " + errors.join("\n"), 83 | QObject::tr("Raw metadata: %1").arg(data) 84 | ); 85 | } 86 | 87 | return metadata; 88 | } 89 | 90 | void MetadataLoader::handleResult() 91 | { 92 | if (ffprobe.exitCode() != 0) 93 | { 94 | emit loadAsyncComplete(Message( 95 | Severity::Error, 96 | tr("Could not retrieve media metadata."), 97 | tr("FFprobe failed: %1").arg(ffprobe.errorString()) 98 | )); 99 | 100 | return; 101 | } 102 | 103 | const QByteArray data = ffprobe.readAll(); 104 | const MetadataResult result = parse(data); 105 | emit loadAsyncComplete(result); 106 | } 107 | 108 | MetadataLoader::MetadataLoader(const PlatformInfo& platformInfo) 109 | : platform(platformInfo) 110 | { 111 | } 112 | 113 | void MetadataLoader::loadAsync(const QString& path) 114 | { 115 | if (ffprobe.state() == QProcess::Running) 116 | return; 117 | 118 | ffprobe.start( 119 | QString(R"(ffprobe -v error -print_format json -show_format -show_streams "%1")").arg(path) 120 | ); 121 | 122 | if (!ffprobe.waitForStarted()) 123 | { 124 | emit loadAsyncComplete(Message( 125 | Severity::Error, 126 | tr("Could not retrieve media metadata."), 127 | tr("FFprobe failed: %1").arg(ffprobe.errorString()) 128 | )); 129 | 130 | return; 131 | } 132 | 133 | connect(&ffprobe, &QProcess::finished, this, &MetadataLoader::handleResult, Qt::UniqueConnection); 134 | } 135 | 136 | double MetadataLoader::getFrameRate(QList& errors) 137 | { 138 | const QVariant frameRateData = value(errors, video, "r_frame_rate"); 139 | 140 | if (frameRateData.isNull()) 141 | { 142 | const QVariant nbrFramesData = value(errors, video, "nb_frames"); 143 | const QVariant durationData = value(errors, format, "duration"); 144 | 145 | if (nbrFramesData.isNull() || durationData.isNull()) 146 | { 147 | NotFound(errors, "frame rate"); 148 | return -1; 149 | } 150 | 151 | const double nbrFrames = nbrFramesData.toDouble(); 152 | const double duration = durationData.toDouble(); 153 | 154 | return nbrFrames / duration; 155 | } 156 | 157 | QStringList frameRateRatio = frameRateData.toString().split("/"); 158 | 159 | if (frameRateRatio.size() != 2) 160 | { 161 | NotFound(errors, "frame rate"); 162 | return -1; 163 | } 164 | 165 | return frameRateRatio.first().toDouble() / frameRateRatio.last().toDouble(); 166 | } 167 | 168 | std::pair MetadataLoader::getAspectRatio(QList& errors) 169 | { 170 | const QVariant aspectRatioData = value(errors, video, "display_aspect_ratio"); 171 | 172 | if (aspectRatioData.isNull()) 173 | { 174 | const double width = value(errors, video, "width").toDouble(); 175 | const double height = value(errors, video, "height").toDouble(); 176 | double ratio = width / height; 177 | 178 | return { ratio, 1 }; 179 | } 180 | 181 | QStringList aspectRatio = aspectRatioData.toString().split(":"); 182 | 183 | if (aspectRatio.size() != 2) 184 | { 185 | NotFound(errors, "aspect ratio"); 186 | return {}; 187 | } 188 | 189 | return { aspectRatio.first().toDouble(), aspectRatio.last().toDouble() }; 190 | } 191 | -------------------------------------------------------------------------------- /core/encoder/encoder_options_builder.cpp: -------------------------------------------------------------------------------- 1 | #include "encoder_options_builder.hpp" 2 | 3 | #include 4 | 5 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::useMetadata(const Metadata& metadata) 6 | { 7 | this->inputMetadata = metadata; 8 | return *this; 9 | } 10 | 11 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::inputFrom(const QString& inputPath) 12 | { 13 | if (inputPath.isEmpty()) 14 | { 15 | errors.append(QObject::tr("Input path is empty.")); 16 | return *this; 17 | } 18 | 19 | if (!QFile::exists(inputPath)) 20 | { 21 | errors.append(QObject::tr("No file exists at input path '%1'.").arg(inputPath)); 22 | return *this; 23 | } 24 | 25 | this->inputPath = inputPath; 26 | return *this; 27 | } 28 | 29 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::outputTo(const QString& outputPath) 30 | { 31 | if (outputPath.isEmpty()) 32 | { 33 | errors.append(QObject::tr("Output path is empty.")); 34 | return *this; 35 | } 36 | 37 | this->outputPath = outputPath; 38 | return *this; 39 | } 40 | 41 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withVideoCodec(const Codec& codec) 42 | { 43 | this->videoCodec = codec; 44 | return *this; 45 | } 46 | 47 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withAudioCodec(const Codec& codec) 48 | { 49 | this->audioCodec = codec; 50 | return *this; 51 | } 52 | 53 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withContainer(const Container& container) 54 | { 55 | this->container = container; 56 | return *this; 57 | } 58 | 59 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withTargetOutputSize(double sizeKbps) 60 | { 61 | if (sizeKbps == 0) 62 | { // auto-mode 63 | return *this; 64 | } 65 | 66 | if (sizeKbps <= 0) 67 | { 68 | errors.append(QObject::tr("Target output size must be greater than 0.")); 69 | return *this; 70 | } 71 | 72 | this->sizeKbps = sizeKbps; 73 | return *this; 74 | } 75 | 76 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withAudioQuality(double audioQualityPercent) 77 | { 78 | if (audioQualityPercent < 0 || audioQualityPercent > 100) 79 | { 80 | errors.append(QObject::tr("Audio quality must be between 0 and 100.")); 81 | return *this; 82 | } 83 | 84 | this->audioQualityPercent = audioQualityPercent; 85 | return *this; 86 | } 87 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withAudioChannelsCount(const int audioChannelsCount) 88 | { 89 | if (audioChannelsCount == 0) // auto-mode 90 | return *this; 91 | 92 | if (audioChannelsCount <= 0) 93 | { 94 | errors.append(QObject::tr("Audio channels count must be greater than 0.")); 95 | return *this; 96 | } 97 | 98 | this->audioChannelsCount = audioChannelsCount; 99 | return *this; 100 | } 101 | 102 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withOutputWidth(int outputWidth) 103 | { 104 | if (outputWidth == 0) // auto-mode 105 | return *this; 106 | 107 | if (outputWidth <= 0) 108 | { 109 | errors.append(QObject::tr("Output width must be greater than 0.")); 110 | return *this; 111 | } 112 | 113 | this->outputWidth = outputWidth; 114 | return *this; 115 | } 116 | 117 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withOutputHeight(int outputHeight) 118 | { 119 | if (outputHeight == 0) // auto-mode 120 | return *this; 121 | 122 | if (outputHeight <= 0) 123 | { 124 | errors.append(QObject::tr("Output height must be greater than 0.")); 125 | return *this; 126 | } 127 | 128 | this->outputHeight = outputHeight; 129 | return *this; 130 | } 131 | 132 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withAspectRatio(const QPoint& aspectRatio) 133 | { 134 | if (aspectRatio.x() == 0 || aspectRatio.y() == 0) // auto-mode 135 | return *this; 136 | 137 | if (aspectRatio.x() < 0 || aspectRatio.y() < 0) 138 | { 139 | errors.append(QObject::tr("Aspect ratio components must be greater than 0.")); 140 | return *this; 141 | } 142 | 143 | if (aspectRatio.y() == 0) 144 | { 145 | errors.append(QObject::tr("Aspect ratio denominator must be greater than 0.")); 146 | return *this; 147 | } 148 | 149 | this->aspectRatio = aspectRatio; 150 | return *this; 151 | } 152 | 153 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::atFps(int fps) 154 | { 155 | if (fps == 0) // auto-mode 156 | return *this; 157 | 158 | if (fps <= 0) 159 | { 160 | errors.append(QObject::tr("FPS must be greater than 0.")); 161 | return *this; 162 | } 163 | 164 | this->fps = fps; 165 | return *this; 166 | } 167 | 168 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::atSpeed(double speed) 169 | { 170 | if (speed == 0) // auto-mode 171 | return *this; 172 | 173 | if (speed < 0) 174 | { 175 | errors.append(QObject::tr("Speed must not be lower than 0.")); 176 | return *this; 177 | } 178 | 179 | this->speed = speed; 180 | return *this; 181 | } 182 | 183 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withMinVideoBitrate(double bitrateKbps) 184 | { 185 | if (bitrateKbps <= 0) 186 | { 187 | errors.append(QObject::tr("Minimum video bitrate must be greater than 0.")); 188 | return *this; 189 | } 190 | 191 | this->minVideoBitrateKbps = bitrateKbps; 192 | return *this; 193 | } 194 | 195 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withMinAudioBitrate(double bitrateKbps) 196 | { 197 | if (bitrateKbps <= 0) 198 | { 199 | errors.append(QObject::tr("Minimum audio bitrate must be greater than 0.")); 200 | return *this; 201 | } 202 | 203 | this->minAudioBitrateKbps = bitrateKbps; 204 | return *this; 205 | } 206 | 207 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withMaxAudioBitrate(double bitrateKbps) 208 | { 209 | if (bitrateKbps <= 0) 210 | { 211 | errors.append(QObject::tr("Maximum audio bitrate must be greater than 0.")); 212 | return *this; 213 | } 214 | 215 | this->maxAudioBitrateKbps = bitrateKbps; 216 | return *this; 217 | } 218 | 219 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withOvershootCorrection(double overshootCorrectionPercent) 220 | { 221 | this->overshootCorrectionPercent = overshootCorrectionPercent; 222 | return *this; 223 | } 224 | 225 | EncoderOptionsBuilder::self& EncoderOptionsBuilder::withCustomArguments(const QString& customArguments) 226 | { 227 | this->customArguments = customArguments; 228 | return *this; 229 | } 230 | 231 | std::variant> EncoderOptionsBuilder::build() 232 | { 233 | if (!inputMetadata.has_value()) 234 | errors.append(QObject::tr("No input metadata was specified.")); 235 | 236 | if (!inputPath.has_value()) 237 | errors.append(QObject::tr("No input path was specified.")); 238 | 239 | if (!outputPath.has_value()) 240 | errors.append(QObject::tr("No output path was specified.")); 241 | 242 | if (!videoCodec.has_value() && !audioCodec.has_value()) 243 | errors.append(QObject::tr("Neither a video or audio codec was specified.")); 244 | 245 | if (!container.has_value()) 246 | errors.append(QObject::tr("No container was specified.")); 247 | 248 | if (minAudioBitrateKbps > maxAudioBitrateKbps) 249 | errors.append(QObject::tr("Minimum audio bitrate must be less than or equal to maximum audio bitrate.")); 250 | 251 | if (!errors.isEmpty()) 252 | return errors; 253 | 254 | // TODO: Should we use std::move? I have to read on move semantics lol 255 | return EncoderOptions { 256 | .inputMetadata = *inputMetadata, 257 | .inputPath = *inputPath, 258 | .outputPath = *outputPath, 259 | .videoCodec = videoCodec, 260 | .audioCodec = audioCodec, 261 | .container = *container, 262 | .sizeKbps = sizeKbps, 263 | .audioQualityPercent = audioQualityPercent, 264 | .audioChannelsCount = audioChannelsCount, 265 | .outputWidth = outputWidth, 266 | .outputHeight = outputHeight, 267 | .aspectRatio = aspectRatio, 268 | .fps = fps, 269 | .speed = speed, 270 | .minVideoBitrateKbps = minVideoBitrateKbps, 271 | .minAudioBitrateKbps = minAudioBitrateKbps, 272 | .maxAudioBitrateKbps = maxAudioBitrateKbps, 273 | .overshootCorrectionPercent = overshootCorrectionPercent, 274 | .customArguments = customArguments 275 | }; 276 | } 277 | -------------------------------------------------------------------------------- /core/encoder/encoder.cpp: -------------------------------------------------------------------------------- 1 | #include "encoder.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "core/formats/metadata.hpp" 10 | #include "core/notifier/message.hpp" 11 | 12 | MediaEncoder::MediaEncoder() 13 | { 14 | ffmpeg->setProcessChannelMode(QProcess::MergedChannels); 15 | connect(ffmpeg, &QProcess::errorOccurred, [this](QProcess::ProcessError error) 16 | { 17 | emit encodingFailed(tr("Process %1").arg(QVariant::fromValue(error).toString())); 18 | }); 19 | } 20 | 21 | void MediaEncoder::Encode(const EncoderOptions& options) 22 | { 23 | const Metadata metadata = options.inputMetadata; 24 | 25 | ComputedOptions computed; 26 | 27 | if (options.audioCodec.has_value()) 28 | { 29 | if (!computeAudioBitrate(options, computed)) 30 | return; 31 | } 32 | 33 | if (options.videoCodec.has_value() && options.sizeKbps.has_value()) 34 | { 35 | ComputeVideoBitrate(options, computed, metadata); 36 | } 37 | 38 | StartCompression(options, computed, metadata); 39 | } 40 | 41 | void MediaEncoder::StartCompression(const EncoderOptions& options, const ComputedOptions& computed, const Metadata& metadata) 42 | { 43 | emit encodingStarted(computed.videoBitrateKbps.value_or(0), computed.audioBitrateKbps.value_or(0)); 44 | 45 | QString baseParams = BuildBaseParams(options, computed); 46 | QString videoFiltersParams = BuildVideoFilterParams(options, computed); 47 | QString audioFiltersParams = BuildAudioFilterParams(options, computed); 48 | 49 | const auto maybeFileExtension = extensionForContainer(options.container); 50 | if (std::holds_alternative(maybeFileExtension)) 51 | { 52 | emit encodingFailed(std::get(maybeFileExtension).message); 53 | return; 54 | } 55 | 56 | const QString fileExtension = std::get(maybeFileExtension); 57 | QString outputPath = options.outputPath + "." + fileExtension; 58 | 59 | const QString command = QString(R"(ffmpeg -i "%1" -c:s copy %2 %3 %4 %5 "%6" -y)") 60 | .arg(options.inputPath, baseParams, videoFiltersParams, audioFiltersParams, *options.customArguments, outputPath); 61 | 62 | processUpdateConnection = connect(ffmpeg, &QProcess::readyRead, [metadata, this] 63 | { 64 | UpdateProgress(metadata.durationSeconds); 65 | }); 66 | 67 | processFinishedConnection = connect(ffmpeg, &QProcess::finished, [=, this](const int exitCode) 68 | { 69 | EndCompression(options, computed, outputPath, command, exitCode); 70 | }); 71 | 72 | ffmpeg->startCommand(command); 73 | } 74 | 75 | void MediaEncoder::UpdateProgress(double mediaDuration) 76 | { 77 | const QString line(ffmpeg->readAll()); 78 | const QRegularExpression regex("time=([0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9])"); 79 | const QRegularExpressionMatch match = regex.match(line); 80 | 81 | output += line; 82 | 83 | if (!match.hasMatch()) 84 | return; 85 | 86 | const QTime timestamp = QTime::fromString(match.captured(1)); 87 | const int currentDuration = timestamp.second() + timestamp.minute() * 60 + timestamp.hour() * 3600; 88 | const int progressPercent = currentDuration * 100 / mediaDuration; 89 | 90 | emit encodingProgressUpdate(progressPercent); 91 | } 92 | 93 | void MediaEncoder::EndCompression(const EncoderOptions& options, const ComputedOptions& computed, QString outputPath, QString command, int exitCode) 94 | { 95 | if (exitCode != 0) 96 | { 97 | disconnect(processUpdateConnection); 98 | disconnect(processFinishedConnection); 99 | 100 | emit encodingFailed(parseOutput(), command + "\n\n" + output); 101 | output.clear(); 102 | return; 103 | } 104 | 105 | QFile media(outputPath); 106 | if (!media.open(QIODevice::ReadOnly)) 107 | { 108 | disconnect(processUpdateConnection); 109 | disconnect(processFinishedConnection); 110 | emit encodingFailed("Could not open the compressed media.", media.errorString()); 111 | output.clear(); 112 | media.close(); 113 | return; 114 | } 115 | 116 | media.close(); 117 | disconnect(processUpdateConnection); 118 | disconnect(processFinishedConnection); 119 | emit encodingSucceeded(options, computed, media); 120 | output.clear(); 121 | } 122 | 123 | QString MediaEncoder::BuildBaseParams(const EncoderOptions& options, const ComputedOptions& computed) const 124 | { 125 | const QString videoCodecParam = options.videoCodec.has_value() ? "-c:v " + options.videoCodec->libraryName : "-vn"; 126 | const QString audioCodecParam = options.audioCodec.has_value() ? "-c:a " + options.audioCodec->libraryName : "-an"; 127 | const QString videoBitrateParam = options.sizeKbps.has_value() ? "-b:v " + QString::number(*computed.videoBitrateKbps) + "k" : ""; 128 | const QString audioBitrateParam = computed.audioBitrateKbps.has_value() ? "-b:a " + QString::number(*computed.audioBitrateKbps) + "k" : ""; 129 | const QString audioChannelsParam = options.audioChannelsCount.has_value() ? "-ac " + QString::number(*options.audioChannelsCount) : ""; 130 | const QString formatParam = QString("-f %1").arg(options.container.formatName); 131 | 132 | QStringList params { videoCodecParam, audioCodecParam, videoBitrateParam, 133 | audioBitrateParam, audioChannelsParam, formatParam }; 134 | params.removeAll({}); 135 | 136 | return params.join(" "); 137 | } 138 | 139 | QString MediaEncoder::BuildVideoFilterParams(const EncoderOptions& options, const ComputedOptions& computed) const 140 | { 141 | QString aspectRatioFilter; 142 | QString scaleFilter; 143 | if (options.outputWidth.has_value() && options.outputHeight.has_value()) 144 | { 145 | scaleFilter = QString("scale=%1:%2").arg(QString::number(*options.outputWidth), QString::number(*options.outputHeight)); 146 | aspectRatioFilter = "setsar=1/1"; 147 | } 148 | else if (options.outputWidth.has_value()) 149 | { 150 | scaleFilter = QString("scale=%1:-2").arg(QString::number(*options.outputWidth)); 151 | } 152 | else if (options.outputHeight.has_value()) 153 | { 154 | scaleFilter = QString("scale=-1:%1").arg(QString::number(*options.outputHeight)); 155 | } 156 | 157 | if (options.aspectRatio.has_value()) 158 | { 159 | aspectRatioFilter = QString("setsar=%1/%2") 160 | .arg(QString::number(options.aspectRatio->y()), QString::number(options.aspectRatio->x())); 161 | } 162 | 163 | QString speedFilter; 164 | double fps = *options.fps; 165 | if (options.speed.has_value()) 166 | { 167 | speedFilter = QString("setpts=%1*PTS").arg(QString::number(1.0 / *options.speed)); 168 | fps *= *options.speed; 169 | } 170 | 171 | QString fpsFilter; 172 | if (options.fps.has_value()) 173 | { 174 | fpsFilter = "fps=" + QString::number(fps); 175 | } 176 | 177 | QStringList videoFilters { scaleFilter, aspectRatioFilter, speedFilter, fpsFilter }; 178 | videoFilters.removeAll({}); 179 | 180 | return videoFilters.empty() ? "" : "-filter:v " + videoFilters.join(','); 181 | } 182 | 183 | QString MediaEncoder::BuildAudioFilterParams(const EncoderOptions& options, const ComputedOptions& computed) const 184 | { 185 | QString audioSpeedFilter; 186 | if (options.speed.has_value()) 187 | { 188 | audioSpeedFilter = "atempo=" + QString::number(*options.speed); 189 | } 190 | 191 | QStringList audioFilters { audioSpeedFilter }; 192 | audioFilters.removeAll({}); 193 | 194 | return audioFilters.empty() ? "" : "-filter:a " + audioFilters.join(','); 195 | } 196 | 197 | QString MediaEncoder::getAvailableFormats() const 198 | { 199 | ffmpeg->startCommand("ffmpeg -encoders"); 200 | ffmpeg->waitForFinished(); 201 | return ffmpeg->readAllStandardOutput(); 202 | } 203 | 204 | bool MediaEncoder::computeAudioBitrate(const EncoderOptions& options, ComputedOptions& computed) const 205 | { 206 | double audioBitrateKbps = qMax(options.minAudioBitrateKbps, options.audioQualityPercent.value_or(1) * options.maxAudioBitrateKbps); 207 | // TODO: Using the strategy pattern, specialize certain codecs to use different bitrate formulas 208 | 209 | computed.audioBitrateKbps = audioBitrateKbps; 210 | return true; 211 | } 212 | 213 | double MediaEncoder::computePixelRatio(const EncoderOptions& options, const Metadata& metadata) const 214 | { 215 | double pixelRatio = 1; 216 | int outputWidth; 217 | int outputHeight; 218 | 219 | const long inputPixelCount = metadata.width * metadata.height; 220 | 221 | if (options.outputWidth.has_value()) 222 | { 223 | outputHeight = *options.outputHeight; 224 | outputWidth = outputHeight * metadata.aspectRatioX / metadata.aspectRatioY; 225 | } 226 | else 227 | { 228 | outputWidth = *options.outputWidth; 229 | outputHeight = outputWidth * metadata.aspectRatioX / metadata.aspectRatioY; 230 | } 231 | 232 | const double outputPixelCount = outputWidth * outputHeight; 233 | 234 | // TODO: Add option to enable bitrate compensation even when upscaling (will result in bigger files) 235 | if (outputPixelCount > 0 && outputPixelCount < inputPixelCount) 236 | pixelRatio = outputPixelCount / inputPixelCount; 237 | 238 | return pixelRatio; 239 | } 240 | 241 | std::variant MediaEncoder::extensionForContainer(const Container& container) const 242 | { 243 | QProcess process; 244 | const QString command = QString("ffmpeg -hide_banner -h muxer=%1").arg(container.formatName); 245 | 246 | process.startCommand(command); 247 | 248 | if (const bool result = process.waitForFinished(10000); !result) 249 | { 250 | return Message(Severity::Critical, tr("Failed to query file extension for container"), tr("FFmpeg did not respond in time to query the file extension for container %1.").arg(container.formatName), process.readAllStandardError()); 251 | } 252 | 253 | const QString output = process.readAllStandardOutput(); 254 | static QRegularExpression regex(R"(Common extensions: (.+(?=\.)))"); 255 | const QRegularExpressionMatch match = regex.match(output); 256 | 257 | if (!match.hasMatch()) 258 | { 259 | return Message(Severity::Critical, tr("Failed to query file extension for container"), tr("FFmpeg did not return a file extension for container %1.").arg(container.formatName), output); 260 | } 261 | 262 | QStringList extensions = match.captured(1).split(","); 263 | 264 | if (extensions.isEmpty()) 265 | { 266 | return Message(Severity::Critical, tr("Failed to query file extension for container"), tr("FFmpeg did not return a file extension for container %1.").arg(container.formatName), output); 267 | } 268 | 269 | return extensions.first().trimmed(); 270 | } 271 | 272 | void MediaEncoder::ComputeVideoBitrate(const EncoderOptions& options, ComputedOptions& computed, const Metadata& metadata) const 273 | { 274 | const double audioBitrateKbps = computed.audioBitrateKbps.value_or(0); 275 | 276 | const double pixelRatio = computePixelRatio(options, metadata); 277 | const double bitrateKbps = *options.sizeKbps / metadata.durationSeconds * (1.0 - options.overshootCorrectionPercent); 278 | 279 | computed.videoBitrateKbps = qMax(options.minVideoBitrateKbps, pixelRatio * (bitrateKbps - audioBitrateKbps)); 280 | } 281 | 282 | QString MediaEncoder::parseOutput() const 283 | { 284 | QStringList split = output.split("Press [q] to stop, [?] for help"); 285 | if (split.length() == 1) 286 | split = output.split("[0][0][0][0]"); 287 | 288 | return split.last() 289 | .replace(QRegularExpression(R"((\[.*\]|(?:Conversion failed!)|(?:v\d\.\d.*)|(?: (?:\s)+)|(?:- (?:\s)+(?1))))"), "") 290 | .trimmed(); 291 | } 292 | -------------------------------------------------------------------------------- /core/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "encoder/encoder_options_builder.hpp" 13 | #include "mainwindow.hpp" 14 | #include "notifier/notifier.hpp" 15 | #include "settings/serializer.hpp" 16 | #include "ui_mainwindow.h" 17 | 18 | using std::optional; 19 | 20 | MainWindow::MainWindow( 21 | MediaEncoder& encoder, 22 | std::shared_ptr settings, 23 | std::shared_ptr presetsSettings, 24 | std::shared_ptr serializer, 25 | MetadataLoader& metadata, 26 | Notifier& notifier, 27 | PlatformInfo& platformInfo, 28 | FormatSupportLoader& formatSupportLoader 29 | ) 30 | : ui(new Ui::MainWindow) 31 | , overlay(new OverlayWidget(this)) 32 | , warnings(new Warnings(ui->warningTooltipButton)) 33 | , menu(new QMenu(this)) 34 | , encoder(encoder) 35 | , settings(settings) 36 | , presetsSettings(std::move(presetsSettings)) 37 | , serializer(std::move(serializer)) 38 | , metadataLoader(metadata) 39 | , notifier(notifier) 40 | , platformInfo(platformInfo) 41 | , formatSupport(formatSupportLoader) 42 | { 43 | CheckForFFmpeg(); 44 | 45 | ui->setupUi(this); 46 | this->resize(this->QWidget::minimumSizeHint()); 47 | 48 | overlay->setGeometry(this->rect()); 49 | overlay->hide(); 50 | overlay->raise(); 51 | 52 | ui->mainHeading->setText(QApplication::applicationName()); 53 | 54 | ui->audioVideoButtonGroup->setId(ui->radVideoAudio, 0); 55 | ui->audioVideoButtonGroup->setId(ui->radVideoOnly, 1); 56 | ui->audioVideoButtonGroup->setId(ui->radAudioOnly, 2); 57 | 58 | preferenceWidgets = std::make_unique>(QList { 59 | ui->advancedModeCheckBox, 60 | ui->audioVideoButtonGroup, 61 | ui->outputFileNameLineEdit, 62 | ui->outputFolderLineEdit, 63 | ui->autoFillCheckBox, 64 | ui->closeOnSuccessCheckBox, 65 | ui->commonFormatsOnlyCheckbox, 66 | ui->deleteOnSuccessCheckBox, 67 | ui->inputFileLineEdit, 68 | ui->openExplorerOnSuccessCheckBox, 69 | ui->outputFileNameSuffixCheckBox, 70 | ui->playOnSuccessCheckBox, 71 | ui->warnOnOverwriteCheckBox, 72 | }); 73 | 74 | presetWidgets = std::make_unique>(QList { 75 | ui->aspectRatioSpinBoxH, 76 | ui->aspectRatioSpinBoxV, 77 | ui->audioCodecComboBox, 78 | ui->audioQualitySlider, 79 | ui->containerComboBox, 80 | ui->customCommandTextEdit, 81 | ui->fileSizeSpinBox, 82 | ui->fileSizeUnitComboBox, 83 | ui->fpsSpinBox, 84 | ui->heightSpinBox, 85 | ui->speedSpinBox, 86 | ui->videoCodecComboBox, 87 | ui->widthSpinBox, 88 | ui->audioChannelCountSpinbox, 89 | }); 90 | 91 | videoControls = std::make_unique>(QList { 92 | ui->videoCodecComboBox, 93 | ui->widthSpinBox, 94 | ui->heightSpinBox, 95 | ui->aspectRatioSpinBoxH, 96 | ui->aspectRatioSpinBoxV, 97 | ui->fpsSpinBox, 98 | ui->speedSpinBox, 99 | }); 100 | 101 | audioControls = std::make_unique>(QList { 102 | ui->audioCodecComboBox, 103 | ui->audioQualitySlider, 104 | }); 105 | 106 | SetupAnimations(); 107 | SetupMenu(); 108 | SetupEventCallbacks(); 109 | 110 | QuerySupportedFormatsAsync(); 111 | } 112 | 113 | MainWindow::~MainWindow() 114 | { 115 | delete ui; 116 | } 117 | 118 | void MainWindow::CheckForFFmpeg() const 119 | { 120 | const int ffmpegReturnCode = QProcess::execute("ffmpeg", QStringList() << "-version"); 121 | const int ffprobeReturnCode = QProcess::execute("ffprobe", QStringList() << "-version"); 122 | 123 | if (ffmpegReturnCode == 0 && ffprobeReturnCode == 0) 124 | return; 125 | 126 | notifier.Notify( 127 | Critical, tr("Could not locate FFmpeg"), 128 | tr("No valid install of FFmpeg was located. Please make sure FFmpeg and FFprobe are in your PATH, or directly " 129 | "in the application directory.") 130 | ); 131 | } 132 | 133 | void MainWindow::SetupMenu() 134 | { 135 | menu->addAction(tr("Help"), &QWhatsThis::enterWhatsThisMode); 136 | menu->addSeparator(); 137 | menu->addAction(tr("About"), this, &MainWindow::ShowAbout); 138 | menu->addAction(tr("About Qt"), &QApplication::aboutQt); 139 | 140 | ui->infoMenuToolButton->setMenu(menu.get()); 141 | } 142 | 143 | void MainWindow::SetupEventCallbacks() 144 | { 145 | connect(&formatSupport, &FormatSupportLoader::queryCompleted, this, &MainWindow::HandleFormatsQueryResult); 146 | 147 | connect(&encoder, &MediaEncoder::encodingStarted, this, &MainWindow::HandleStart); 148 | connect(&encoder, &MediaEncoder::encodingSucceeded, this, &MainWindow::HandleSuccess); 149 | connect(&encoder, &MediaEncoder::encodingFailed, this, &MainWindow::HandleFailure); 150 | connect(&encoder, &MediaEncoder::encodingProgressUpdate, this, [this](int progress) 151 | { SetProgressShown({ .status = tr("Compressing..."), .progressPercent = progress }); }); 152 | } 153 | 154 | void MainWindow::QuerySupportedFormatsAsync() const 155 | { 156 | SetProgressShown({ .status = tr("Querying supported formats...") }); 157 | formatSupport.QuerySupportedFormatsAsync(); 158 | } 159 | 160 | void MainWindow::LoadState() 161 | { 162 | const QString key = "Preferences"; 163 | 164 | serializer->deserialize(ui->advancedModeCheckBox, settings, key); 165 | SetAdvancedMode(ui->advancedModeCheckBox->isChecked()); 166 | 167 | serializer->deserialize(ui->audioVideoButtonGroup, settings, key); 168 | UpdateControlsState(); 169 | 170 | serializer->deserialize(ui->outputFileNameLineEdit, settings, key); 171 | LoadSelectedUrl(); 172 | 173 | serializer->deserialize(ui->outputFolderLineEdit, settings, key); 174 | ValidateSelectedDir(); 175 | 176 | serializer->deserialize(ui->commonFormatsOnlyCheckbox, settings, "Preferences"); 177 | UpdateCodecsList(ui->commonFormatsOnlyCheckbox->isChecked()); 178 | 179 | LoadPresetNames(); 180 | 181 | const QList widgets = { 182 | ui->autoFillCheckBox, 183 | ui->closeOnSuccessCheckBox, 184 | ui->deleteOnSuccessCheckBox, 185 | ui->inputFileLineEdit, 186 | ui->openExplorerOnSuccessCheckBox, 187 | ui->outputFileNameSuffixCheckBox, 188 | ui->playOnSuccessCheckBox, 189 | ui->warnOnOverwriteCheckBox, 190 | }; 191 | 192 | serializer->deserializeMany(widgets, settings, key); 193 | serializer->deserializeMany(*presetWidgets, settings, "PreviousSettings"); 194 | UpdateControlsState(); 195 | } 196 | 197 | void MainWindow::LoadPresetNames() const 198 | { 199 | ui->qualityPresetComboBox->addItems(presetsSettings->groups()); 200 | } 201 | 202 | void MainWindow::SaveState() const 203 | { 204 | serializer->serializeMany(*preferenceWidgets, settings, "Preferences"); 205 | serializer->serializeMany(*presetWidgets, settings, "PreviousSettings"); 206 | } 207 | 208 | void MainWindow::dragEnterEvent(QDragEnterEvent* event) 209 | { 210 | if (!event->mimeData()->hasUrls()) 211 | { 212 | event->ignore(); 213 | return; 214 | } 215 | 216 | const QMimeDatabase database; 217 | const QUrl url = event->mimeData()->urls().first(); 218 | const QMimeType mimeType = database.mimeTypeForFile(url.toLocalFile()); 219 | 220 | isValidMimeForDrop = mimeType.name().startsWith("image/") 221 | || mimeType.name().startsWith("video/") 222 | || mimeType.name().startsWith("audio/"); 223 | if (isValidMimeForDrop) 224 | { 225 | overlay->setBackgroundColor(QColor(0, 0, 0, 128)); 226 | overlay->setText("Drop to select file"); 227 | } 228 | else 229 | { 230 | overlay->setBackgroundColor(QColor(128, 0, 0, 128)); 231 | overlay->setText("Invalid media file"); 232 | } 233 | 234 | if (!isDragging) 235 | { 236 | overlay->showWithFade(); 237 | isDragging = true; 238 | } 239 | 240 | event->accept(); 241 | } 242 | 243 | void MainWindow::dropEvent(QDropEvent* event) 244 | { 245 | if (!event->mimeData()->hasUrls()) 246 | return; 247 | 248 | if (isValidMimeForDrop) 249 | { 250 | const QUrl url = event->mimeData()->urls().first(); 251 | LoadInputFile(url); 252 | } 253 | 254 | overlay->hideWithFade(); 255 | isDragging = false; 256 | } 257 | 258 | void MainWindow::dragLeaveEvent(QDragLeaveEvent* event) 259 | { 260 | overlay->hideWithFade(); 261 | isDragging = false; 262 | } 263 | 264 | void MainWindow::resizeEvent(QResizeEvent* event) 265 | { 266 | overlay->setGeometry(this->rect()); 267 | QMainWindow::resizeEvent(event); 268 | } 269 | 270 | void MainWindow::closeEvent(QCloseEvent* event) 271 | { 272 | SaveState(); 273 | event->accept(); 274 | } 275 | 276 | void MainWindow::StartEncoding() 277 | { 278 | EncoderOptionsBuilder builder; 279 | 280 | const QString inputPath = ui->inputFileLineEdit->text(); 281 | const QString outputPath = getOutputPath(inputPath); 282 | 283 | // FIXME: emit fileExists() signal 284 | // if (QFile::exists(outputPath + "." + container->formatName) && ui->warnOnOverwriteCheckBox->isChecked() 285 | // && QMessageBox::question(this, "Overwrite?", "Output at path '" + outputPath + "' already exists. Overwrite 286 | // it?") 287 | // == QMessageBox::No) { 288 | // notifier.Notify(Severity::Info, "Operation canceled", "Compression aborted."); 289 | // return; 290 | // } 291 | 292 | if (metadata.has_value()) 293 | builder.useMetadata(*metadata); 294 | 295 | const auto streamType = static_cast(ui->audioVideoButtonGroup->checkedId()); 296 | const bool hasVideo = streamType == VideoAudio || streamType == VideoOnly; 297 | const bool hasAudio = streamType == VideoAudio || streamType == AudioOnly; 298 | 299 | if (hasVideo) 300 | builder.withVideoCodec(ui->videoCodecComboBox->currentData().value()); 301 | 302 | if (hasAudio) 303 | builder.withAudioCodec(ui->audioCodecComboBox->currentData().value()); 304 | 305 | builder.inputFrom(inputPath) 306 | .outputTo(outputPath) 307 | .withContainer(ui->containerComboBox->currentData().value()) 308 | .withTargetOutputSize(getOutputSizeKbps()) 309 | .withAudioQuality(ui->audioQualitySlider->value() / 100.0) 310 | .withAudioChannelsCount(ui->audioChannelCountSpinbox->value()) 311 | .withOutputWidth(ui->widthSpinBox->value()) 312 | .withOutputHeight(ui->heightSpinBox->value()) 313 | .withAspectRatio(QPoint(ui->aspectRatioSpinBoxH->value(), ui->aspectRatioSpinBoxV->value())) 314 | .atFps(ui->fpsSpinBox->value()) 315 | .atSpeed(ui->speedSpinBox->value()) 316 | .withCustomArguments(ui->customCommandTextEdit->toPlainText()) 317 | .withMinVideoBitrate(settings->get("Main/dMinBitrateVideoKbps").toDouble()) 318 | .withMinAudioBitrate(settings->get("Main/dMinBitrateAudioKbps").toDouble()) 319 | .withMaxAudioBitrate(settings->get("Main/dMaxBitrateAudioKbps").toDouble()); 320 | 321 | const auto maybeOptions = builder.build(); 322 | if (std::holds_alternative>(maybeOptions)) 323 | { 324 | notifier.Notify(Severity::Error, "Invalid encoding options", std::get>(maybeOptions).join("\n")); 325 | return; 326 | } 327 | 328 | const EncoderOptions options = std::get(maybeOptions); 329 | encoder.Encode(options); 330 | } 331 | 332 | void MainWindow::HandleStart(double videoBitrateKbps, double audioBitrateKbps) const 333 | { 334 | SetProgressShown({ .status = tr("Compressing..."), .progressPercent = 0 }); 335 | 336 | ui->progressBarLabel->setText( 337 | QString(tr("Video bitrate: %1 kbps | Audio bitrate: %2 kbps")) 338 | .arg(QString::number(qRound(videoBitrateKbps)), QString::number(qRound(audioBitrateKbps))) 339 | ); 340 | } 341 | 342 | void MainWindow::HandleSuccess( 343 | const EncoderOptions& options, const MediaEncoder::ComputedOptions& computed, QFile& output 344 | ) const 345 | { 346 | SetProgressShown({ .status = tr("Compression complete"), .progressPercent = 100 }); 347 | 348 | QString summary; 349 | QString videoBitrate = computed.videoBitrateKbps.has_value() ? QString::number(*computed.videoBitrateKbps) + "kbps" 350 | : "auto-set bitrate"; 351 | 352 | if (options.videoCodec.has_value()) 353 | { 354 | summary += tr("Using video codec %1 at %2 with container %3.\n") 355 | .arg(options.videoCodec->displayName, videoBitrate, options.container.displayName); 356 | } 357 | if (options.audioCodec.has_value()) 358 | { 359 | summary += tr("Using audio codec %1 at %2kbps.\n") 360 | .arg(options.audioCodec->displayName, QString::number(*computed.audioBitrateKbps)); 361 | } 362 | if (options.sizeKbps.has_value()) 363 | { 364 | summary += tr("Requested size was %1 kb.\nActual " 365 | "compression achieved is %2 kb.") 366 | .arg(QString::number(*options.sizeKbps), QString::number(output.size() / 125.0)); 367 | } 368 | 369 | notifier.Notify(Severity::Info, tr("Compressed successfully"), summary); 370 | 371 | SetProgressShown({}); 372 | 373 | const QFileInfo fileInfo(output); 374 | QString command = platformInfo.isWindows() ? "explorer" : "xdg-open"; 375 | 376 | if (ui->deleteOnSuccessCheckBox->isChecked()) 377 | { 378 | QFile input(options.inputPath); 379 | input.open(QIODevice::WriteOnly); 380 | 381 | if (!(input.remove())) 382 | { 383 | notifier.Notify( 384 | Severity::Error, tr("Failed to remove input file"), output.errorString() + "\n\n" + options.inputPath 385 | ); 386 | } 387 | else 388 | { 389 | ui->inputFileLineEdit->clear(); 390 | } 391 | 392 | input.close(); 393 | } 394 | 395 | if (ui->openExplorerOnSuccessCheckBox->isChecked()) 396 | { 397 | QProcess::execute(QString(R"(%1 "%2")").arg(command, fileInfo.dir().path())); 398 | } 399 | 400 | if (ui->playOnSuccessCheckBox->isChecked()) 401 | { 402 | QProcess::execute(QString(R"(%1 "%2")").arg(command, fileInfo.absoluteFilePath())); 403 | } 404 | 405 | if (ui->closeOnSuccessCheckBox->isChecked()) 406 | { 407 | QApplication::exit(0); 408 | } 409 | } 410 | 411 | void MainWindow::HandleFailure(const QString& shortError, const QString& longError) const 412 | { 413 | notifier.Notify(Severity::Warning, tr("Compression failed"), shortError, longError); 414 | SetProgressShown({}); 415 | } 416 | 417 | void MainWindow::CheckAspectRatioConflict() const 418 | { 419 | const bool hasCustomScale = ui->aspectRatioSpinBoxH->value() != 0 || ui->aspectRatioSpinBoxV->value() != 0; 420 | const bool hasCustomAspect = ui->widthSpinBox->value() != 0 || ui->heightSpinBox->value() != 0; 421 | 422 | if (hasCustomScale && hasCustomAspect) 423 | { 424 | warnings->Add( 425 | "aspectRatioConflict", tr("A custom aspect ratio has been set. It will take priority over the " 426 | "one defined by custom scaling.") 427 | ); 428 | } 429 | else 430 | { 431 | warnings->Remove("aspectRatioConflict"); 432 | } 433 | } 434 | 435 | void MainWindow::CheckSpeedConflict() const 436 | { 437 | const bool hasSpeed = ui->speedSpinBox->value() != 0; 438 | const bool hasFps = ui->fpsSpinBox->value() != 0; 439 | 440 | if (hasSpeed && hasFps) 441 | { 442 | warnings->Add( 443 | "speedConflict", tr("A custom speed was set alongside a custom fps; this may cause " 444 | "strange behavior. Note that fps is automatically compensated when " 445 | "changing the speed.") 446 | ); 447 | } 448 | else 449 | { 450 | warnings->Remove("speedConflict"); 451 | } 452 | } 453 | 454 | void MainWindow::SelectOutputDirectory() 455 | { 456 | const QDir dir = QFileDialog::getExistingDirectory(this, tr("Select output directory"), QDir::currentPath()); 457 | ui->outputFolderLineEdit->setText(dir.absolutePath()); 458 | } 459 | 460 | void MainWindow::UpdateAudioQualityLabel(int value) const 461 | { 462 | static double minBitrate = settings->get("Main/dMinBitrateAudioKbps").toDouble(); 463 | static double maxBitrate = settings->get("Main/dMaxBitrateAudioKbps").toDouble(); 464 | const double currentValue = qMax(minBitrate, value / 100.0 * maxBitrate); 465 | 466 | ui->audioQualityDisplayLabel->setText(QString::number(qRound(currentValue)) + " kbps"); 467 | } 468 | 469 | void MainWindow::SetAllowPresetSelection(bool allowed) const { ui->qualityPresetComboBox->setEnabled(!allowed); } 470 | 471 | void MainWindow::HandleFormatsQueryResult(const std::variant, Message>& maybeFormats) 472 | { 473 | if (std::holds_alternative(maybeFormats)) 474 | { 475 | notifier.Notify(std::get(maybeFormats)); 476 | return; 477 | } 478 | 479 | const auto formats = std::get>(maybeFormats); 480 | formatSupportCache = formats; 481 | SetProgressShown({}); 482 | 483 | LoadState(); 484 | LoadSelectedUrl(); 485 | } 486 | 487 | void MainWindow::UpdateCodecsList(const bool commonOnly) const 488 | { 489 | static QStringList commonVideoCodecs = settings->get("FormatSelection/sCommonVideoCodecs").toStringList(); 490 | static QStringList commonAudioCodecs = settings->get("FormatSelection/sCommonAudioCodecs").toStringList(); 491 | static QStringList commonContainers = settings->get("FormatSelection/sCommonContainers").toStringList(); 492 | 493 | ui->videoCodecComboBox->clear(); 494 | ui->audioCodecComboBox->clear(); 495 | ui->containerComboBox->clear(); 496 | 497 | // passing “copy” as codec name will make ffmpeg use the same codec as the input file 498 | static Codec passthroughCodec = { .displayName = "Passthrough", .libraryName = "copy", .isAudioCodec = false }; 499 | ui->videoCodecComboBox->addItem(passthroughCodec.displayName); 500 | ui->videoCodecComboBox->setItemData(0, QVariant::fromValue(passthroughCodec)); 501 | 502 | for (const Codec& videoCodec : formatSupportCache->videoCodecs) 503 | { 504 | QString name = videoCodec.libraryName; 505 | if (commonOnly && !commonVideoCodecs.contains(name)) 506 | continue; 507 | 508 | ui->videoCodecComboBox->addItem(name); 509 | ui->videoCodecComboBox->setItemData(ui->videoCodecComboBox->count() - 1, QVariant::fromValue(videoCodec)); 510 | ui->videoCodecComboBox->setItemData(ui->videoCodecComboBox->count() - 1, videoCodec.displayName, Qt::ToolTipRole); 511 | } 512 | 513 | static Codec passthroughAudioCodec = { .displayName = "Passthrough", .libraryName = "copy", .isAudioCodec = true }; 514 | ui->audioCodecComboBox->addItem(passthroughAudioCodec.displayName); 515 | ui->audioCodecComboBox->setItemData(0, QVariant::fromValue(passthroughAudioCodec)); 516 | for (const Codec& audioCodec : formatSupportCache->audioCodecs) 517 | { 518 | QString name = audioCodec.libraryName; 519 | if (commonOnly && !commonAudioCodecs.contains(name)) 520 | continue; 521 | 522 | ui->audioCodecComboBox->addItem(name); 523 | ui->audioCodecComboBox->setItemData(ui->audioCodecComboBox->count() - 1, QVariant::fromValue(audioCodec)); 524 | ui->audioCodecComboBox->setItemData(ui->audioCodecComboBox->count() - 1, audioCodec.displayName, Qt::ToolTipRole); 525 | } 526 | 527 | for (const Container& container : formatSupportCache->containers) 528 | { 529 | QString name = container.formatName; 530 | if (commonOnly && !commonContainers.contains(name)) 531 | continue; 532 | 533 | ui->containerComboBox->addItem(name); 534 | ui->containerComboBox->setItemData(ui->containerComboBox->count() - 1, QVariant::fromValue(container)); 535 | ui->containerComboBox->setItemData(ui->containerComboBox->count() - 1, container.displayName, Qt::ToolTipRole); 536 | } 537 | } 538 | 539 | void MainWindow::ShowAbout() const 540 | { 541 | /// @todo: Add William to the credits 542 | static const QString msg 543 | = "\r\n

Acknowledgements

\r\n" 544 | 545 | "A convenient graphical frontend for ffmpeg, the media encoding and decoding suite.

\r\n" 546 | "On Linux, uses system ffprobe and ffmpeg.
\r\n" 548 | "On Windows, uses pre-compiled binaries of ffprobe.exe and ffmpeg.exe from gyan.dev.

\r\nBuilt with Qt, the complete toolkit for cross-platform application development, under GPLv3 " 551 | "licensing. See About Qt.

\r\n" 552 | "For more information, visit our GitHub " 553 | "repository.\r\n" 554 | 555 | "

Credits

\r\n" 556 | "Special thanks to Theodore L'Heureux for his helpful advice on refactoring and beta-testing of the " 557 | "product.\r\n"; 558 | 559 | notifier.Notify(Severity::Info, "About " + QApplication::applicationName(), msg); 560 | } 561 | 562 | void MainWindow::SetProgressShown(const ProgressState& state) const 563 | { 564 | if (state.status.has_value() && ui->progressWidget->maximumHeight() == 0) 565 | { 566 | ui->centralWidget->setEnabled(false); 567 | 568 | const QString taskName = *state.status; 569 | if (ui->startCompressionButton->text() != taskName) 570 | ui->startCompressionButton->setText(taskName); 571 | 572 | ui->progressWidgetTopSpacer->changeSize(0, 10); 573 | progressBarHeightAnim->setStartValue(0); 574 | progressBarHeightAnim->setEndValue(500); 575 | progressBarHeightAnim->start(); 576 | } 577 | else if (!state.status) 578 | { 579 | ui->centralWidget->setEnabled(true); 580 | ui->startCompressionButton->setText(tr("Start encoding")); 581 | ui->progressWidgetTopSpacer->changeSize(0, 0); 582 | progressBarHeightAnim->setStartValue(ui->progressWidget->height()); 583 | progressBarHeightAnim->setEndValue(0); 584 | progressBarHeightAnim->start(); 585 | } 586 | 587 | if (!state.progressPercent.has_value()) 588 | { 589 | ui->progressBar->setRange(0, 0); 590 | return; 591 | } 592 | 593 | ui->progressBar->setRange(0, 100); 594 | progressBarValueAnim->setStartValue(ui->progressBar->value()); 595 | progressBarValueAnim->setEndValue(*state.progressPercent); 596 | progressBarValueAnim->start(); 597 | } 598 | 599 | void MainWindow::SetAdvancedMode(bool enabled) const 600 | { 601 | if (enabled) 602 | { 603 | sectionWidthAnim->setStartValue(0); 604 | sectionWidthAnim->setEndValue(1000); 605 | sectionHeightAnim->setStartValue(0); 606 | sectionHeightAnim->setEndValue(1000); 607 | } 608 | else 609 | { 610 | sectionWidthAnim->setStartValue(ui->advancedSection->width()); 611 | sectionWidthAnim->setEndValue(0); 612 | sectionHeightAnim->setStartValue(ui->advancedSection->width()); 613 | sectionHeightAnim->setEndValue(0); 614 | } 615 | 616 | sectionWidthAnim->start(); 617 | sectionHeightAnim->start(); 618 | } 619 | 620 | void MainWindow::UpdateControlsState() const 621 | { 622 | const auto state = static_cast(ui->audioVideoButtonGroup->checkedId()); 623 | const bool isVideoAudio = state == VideoAudio; 624 | const bool isVideoOnly = state == VideoOnly; 625 | const bool isAudioOnly = state == AudioOnly; 626 | 627 | const bool isVideoPassthrough = ui->videoCodecComboBox->currentIndex() == 0; 628 | const bool isAudioPassthrough = ui->audioCodecComboBox->currentIndex() == 0; 629 | 630 | for (QWidget* control : *videoControls) 631 | control->setEnabled((isVideoAudio || isVideoOnly) && (!isVideoPassthrough || control == ui->videoCodecComboBox)); 632 | 633 | for (QWidget* control : *audioControls) 634 | control->setEnabled((isVideoAudio || isAudioOnly) && (!isAudioPassthrough || control == ui->audioCodecComboBox)); 635 | } 636 | 637 | void MainWindow::ShowMetadata() 638 | { 639 | if (!metadata.has_value()) 640 | { 641 | notifier.Notify(Severity::Info, tr("No file selected"), tr("Please select a file to continue.")); 642 | return; 643 | } 644 | 645 | notifier.Notify( 646 | Severity::Info, tr("Metadata"), 647 | tr("Video codec: %1\nAudio codec: %2\nContainer: %3\nAudio bitrate: %4 kbps\n\n " 648 | "(complete data to be implemented in a future update)") 649 | .arg(metadata->videoCodec, metadata->audioCodec, "N/A", QString::number(metadata->audioBitrateKbps)) 650 | ); 651 | } 652 | 653 | void MainWindow::LoadPreset(const int index) const 654 | { 655 | if (index < 0) 656 | return; 657 | 658 | const QString presetName = ui->qualityPresetComboBox->itemText(index); 659 | if (!presetsSettings->groups().contains(presetName)) 660 | return; 661 | 662 | serializer->deserializeMany(*presetWidgets, presetsSettings, presetName); 663 | UpdateControlsState(); 664 | } 665 | 666 | void MainWindow::SelectVideoCodec(const int index) const 667 | { 668 | UpdateControlsState(); 669 | } 670 | 671 | void MainWindow::SelectAudioCodec(const int index) const 672 | { 673 | const bool isPassthrough = index == 0; 674 | 675 | for (QWidget* control : *audioControls) 676 | { 677 | if (control == ui->audioCodecComboBox) 678 | continue; 679 | 680 | control->setEnabled(!isPassthrough); 681 | } 682 | } 683 | 684 | void MainWindow::OpenInputFile() 685 | { 686 | const QUrl fileUrl = QFileDialog::getOpenFileUrl(this, tr("Select file to compress"), QDir::currentPath(), "*"); 687 | if (fileUrl.isValid()) 688 | LoadInputFile(fileUrl); 689 | } 690 | 691 | void MainWindow::QueryMediaMetadataAsync(const QString& path) 692 | { 693 | SetProgressShown({ .status = tr("Parsing metadata...") }); 694 | 695 | connect( 696 | &metadataLoader, &MetadataLoader::loadAsyncComplete, this, &MainWindow::ReceiveMediaMetadata, 697 | Qt::UniqueConnection 698 | ); 699 | 700 | metadataLoader.loadAsync(path); 701 | } 702 | 703 | void MainWindow::ReceiveMediaMetadata(MetadataResult result) 704 | { 705 | SetProgressShown({}); 706 | 707 | if (std::holds_alternative(result)) 708 | { 709 | const Message error = std::get(result); 710 | 711 | notifier.Notify(error); 712 | ui->inputFileLineEdit->clear(); 713 | return; 714 | } 715 | 716 | metadata = std::get(result); 717 | } 718 | 719 | QString MainWindow::getOutputPath(QString inputFilePath) const 720 | { 721 | const QString folder = ui->outputFolderLineEdit->text(); 722 | const bool isSuffix = ui->outputFileNameSuffixCheckBox->isChecked(); 723 | QString fileNameOrSuffix = ui->outputFileNameLineEdit->text(); 724 | const QFileInfo inputFile(inputFilePath); 725 | 726 | const QDir resolvedFolder = folder.isEmpty() ? inputFile.dir() : QDir(folder); 727 | QString resolvedFileName; 728 | 729 | if (fileNameOrSuffix.isEmpty()) 730 | { 731 | resolvedFileName = inputFile.fileName(); 732 | } 733 | else if (isSuffix) 734 | { 735 | if (!fileNameOrSuffix[0].isLetterOrNumber()) 736 | fileNameOrSuffix.remove(0, 1); 737 | 738 | resolvedFileName = inputFile.completeBaseName() + "_" + fileNameOrSuffix; 739 | } 740 | else 741 | { 742 | resolvedFileName = fileNameOrSuffix; 743 | } 744 | 745 | return resolvedFolder.filePath(resolvedFileName); 746 | } 747 | 748 | bool MainWindow::isAutoValue(QAbstractSpinBox* spinBox) const { return spinBox->text() == spinBox->specialValueText(); } 749 | 750 | void MainWindow::LoadSelectedUrl() 751 | { 752 | const QString selectedUrl = ui->inputFileLineEdit->text(); 753 | const bool isValidInput = QFile::exists(selectedUrl); 754 | if (isValidInput) 755 | QueryMediaMetadataAsync(selectedUrl); 756 | else 757 | ui->inputFileLineEdit->clear(); 758 | } 759 | void MainWindow::LoadInputFile(const QUrl& url) 760 | { 761 | const QString path = url.toLocalFile(); 762 | ui->inputFileLineEdit->setText(path); 763 | 764 | QueryMediaMetadataAsync(path); 765 | 766 | if (ui->autoFillCheckBox->isChecked()) 767 | { 768 | ui->widthSpinBox->setValue(metadata->width); 769 | ui->heightSpinBox->setValue(metadata->height); 770 | ui->speedSpinBox->setValue(1); 771 | ui->fileSizeSpinBox->setValue(metadata->sizeKbps); 772 | ui->fileSizeUnitComboBox->setCurrentIndex(0); 773 | ui->aspectRatioSpinBoxH->setValue(metadata->aspectRatioX); 774 | ui->aspectRatioSpinBoxV->setValue(metadata->aspectRatioY); 775 | ui->fpsSpinBox->setValue(metadata->frameRate); 776 | 777 | const int qualityPercent = metadata->audioBitrateKbps * 100 / 256; 778 | ui->audioQualitySlider->setValue(qualityPercent); 779 | } 780 | } 781 | 782 | void MainWindow::ValidateSelectedDir() const 783 | { 784 | const QString selectedDir = ui->outputFolderLineEdit->text(); 785 | const bool isValidOutput = QDir(selectedDir).exists(); 786 | if (!isValidOutput) 787 | ui->outputFolderLineEdit->clear(); 788 | 789 | ui->warningTooltipButton->setVisible(false); 790 | } 791 | 792 | void MainWindow::SetupAnimations() 793 | { 794 | progressBarValueAnim = std::make_unique(); 795 | progressBarValueAnim->setTargetObject(ui->progressBar); 796 | progressBarValueAnim->setPropertyName("value"); 797 | progressBarValueAnim->setDuration(settings->get("Main/iProgressBarAnimDurationMs").toInt()); 798 | progressBarValueAnim->setEasingCurve(QEasingCurve::OutQuad); 799 | 800 | progressBarHeightAnim = std::make_unique(); 801 | progressBarHeightAnim->setTargetObject(ui->progressWidget); 802 | progressBarHeightAnim->setPropertyName("maximumHeight"); 803 | progressBarHeightAnim->setDuration(settings->get("Main/iProgressWidgetAnimDurationMs").toInt()); 804 | progressBarHeightAnim->setEasingCurve(QEasingCurve::InOutQuad); 805 | 806 | const int duration = settings->get("Main/iSectionAnimDurationMs").toInt(); 807 | 808 | sectionWidthAnim = std::make_unique(); 809 | sectionWidthAnim->setTargetObject(ui->advancedSection); 810 | sectionWidthAnim->setPropertyName("maximumWidth"); 811 | sectionWidthAnim->setDuration(duration); 812 | sectionWidthAnim->setEasingCurve(QEasingCurve::InOutQuad); 813 | 814 | sectionHeightAnim = std::make_unique(); 815 | sectionHeightAnim->setTargetObject(ui->advancedSection); 816 | sectionHeightAnim->setPropertyName("maximumHeight"); 817 | sectionHeightAnim->setDuration(duration); 818 | sectionHeightAnim->setEasingCurve(QEasingCurve::InOutQuad); 819 | 820 | windowSizeAnim = std::make_unique(); 821 | windowSizeAnim->setTargetObject(this); 822 | windowSizeAnim->setPropertyName("size"); 823 | windowSizeAnim->setDuration(duration); 824 | windowSizeAnim->setEasingCurve(QEasingCurve::InOutQuad); 825 | 826 | connect(sectionWidthAnim.get(), &QPropertyAnimation::finished, windowSizeAnim.get(), [this] 827 | { 828 | windowSizeAnim->setStartValue(this->size()); 829 | windowSizeAnim->setEndValue(this->minimumSizeHint()); 830 | windowSizeAnim->start(); }); 831 | } 832 | 833 | double MainWindow::getOutputSizeKbps() const 834 | { 835 | double sizeKbpsConversionFactor = 0; 836 | 837 | switch (ui->fileSizeUnitComboBox->currentIndex()) 838 | { 839 | case 0: // KB to kb 840 | sizeKbpsConversionFactor = 8; 841 | break; 842 | case 1: // MB to kb 843 | sizeKbpsConversionFactor = 8000; 844 | break; 845 | case 2: // GB to kb 846 | sizeKbpsConversionFactor = 8e+6; 847 | break; 848 | } 849 | 850 | return ui->fileSizeSpinBox->value() * sizeKbpsConversionFactor; 851 | } 852 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /ui/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 891 10 | 692 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | 21 | 1000 22 | 1000 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 0 32 | 0 33 | 34 | 35 | 36 | true 37 | 38 | 39 | Click on any area to get help about it. 40 | 41 | 42 | 43 | 0 44 | 45 | 46 | QLayout::SizeConstraint::SetNoConstraint 47 | 48 | 49 | 20 50 | 51 | 52 | 20 53 | 54 | 55 | 20 56 | 57 | 58 | 20 59 | 60 | 61 | 62 | 63 | 64 | 10 65 | 66 | 67 | QLayout::SizeConstraint::SetDefaultConstraint 68 | 69 | 70 | 0 71 | 72 | 73 | 0 74 | 75 | 76 | 0 77 | 78 | 79 | 10 80 | 81 | 82 | 83 | 84 | 85 | Segoe UI Light 86 | 16 87 | 88 | 89 | 90 | App Title 91 | 92 | 93 | 94 | 95 | 96 | 97 | <html><head/><body><p>If checked, advanced options will be available.</p></body></html> 98 | 99 | 100 | Qt::LayoutDirection::RightToLeft 101 | 102 | 103 | Expert mode 104 | 105 | 106 | true 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 0 125 | 0 126 | 127 | 128 | 129 | 130 | 0 131 | 132 | 133 | QLayout::SizeConstraint::SetNoConstraint 134 | 135 | 136 | 137 | 138 | 139 | 0 140 | 0 141 | 142 | 143 | 144 | 145 | QLayout::SizeConstraint::SetDefaultConstraint 146 | 147 | 148 | 0 149 | 150 | 151 | 0 152 | 153 | 154 | 0 155 | 156 | 157 | 0 158 | 159 | 160 | 20 161 | 162 | 163 | 164 | 165 | 1 166 | 167 | 168 | 169 | 170 | 171 | Segoe UI Semibold 172 | 10 173 | false 174 | 175 | 176 | 177 | <html><head/><body><p>These options control behavior post-compression.</p></body></html> 178 | 179 | 180 | After encoding 181 | 182 | 183 | 184 | 185 | 186 | 187 | Qt::Orientation::Vertical 188 | 189 | 190 | QSizePolicy::Policy::Fixed 191 | 192 | 193 | 194 | 20 195 | 5 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | <html><head/><body><p>If checked, the <span style=" font-weight:700;">folder</span> containing the resulting media will be opened upon successful compression.</p></body></html> 204 | 205 | 206 | Open in explorer 207 | 208 | 209 | 210 | 211 | 212 | 213 | <html><head/><body><p>If checked, the resulting media will be opened with the default media player upon successful compression.</p></body></html> 214 | 215 | 216 | Play encoded media 217 | 218 | 219 | 220 | 221 | 222 | 223 | <html><head/><body><p>If checked, this utility will <span style=" font-weight:700;">close</span> itself upon successful compression.</p></body></html> 224 | 225 | 226 | Close this utility 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 5 236 | 237 | 238 | QLayout::SizeConstraint::SetMaximumSize 239 | 240 | 241 | 242 | 243 | 244 | 0 245 | 0 246 | 247 | 248 | 249 | 250 | Segoe UI Semibold 251 | 10 252 | false 253 | 254 | 255 | 256 | Enter output file name 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 0 265 | 0 266 | 267 | 268 | 269 | <html><head/><body><p>Specify the <span style=" font-weight:700;">output file name</span>.</p><p>If <span style=" font-style:italic;">As suffix </span>is checked, the value will be appended to the existing file name instead.</p></body></html> 270 | 271 | 272 | 273 | 274 | 275 | false 276 | 277 | 278 | Leave empty to use input 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | Qt::Orientation::Horizontal 288 | 289 | 290 | 291 | 40 292 | 20 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 0 302 | 0 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | <html><head/><body><p>If checked, the value above will behave as a <span style=" font-weight:700;">suffix</span> to the input file name.</p></body></html> 313 | 314 | 315 | As suffix 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 0 327 | 328 | 329 | 330 | 331 | 332 | 0 333 | 0 334 | 335 | 336 | 337 | 338 | Segoe UI Semibold 339 | 10 340 | 341 | 342 | 343 | Mute and extract audio 344 | 345 | 346 | 347 | 348 | 349 | 350 | Qt::Orientation::Vertical 351 | 352 | 353 | QSizePolicy::Policy::Fixed 354 | 355 | 356 | 357 | 20 358 | 5 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 0 368 | 0 369 | 370 | 371 | 372 | 373 | 16777215 374 | 18 375 | 376 | 377 | 378 | <html><head/><body><p>Select this option to output both video and audio.</p></body></html> 379 | 380 | 381 | Video and audio 382 | 383 | 384 | true 385 | 386 | 387 | audioVideoButtonGroup 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 16777215 396 | 18 397 | 398 | 399 | 400 | <html><head/><body><p>Select this option if you want only video, without audio.</p></body></html> 401 | 402 | 403 | Video only 404 | 405 | 406 | audioVideoButtonGroup 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 16777215 415 | 18 416 | 417 | 418 | 419 | <html><head/><body><p>Select this option if you want audio only, without video.</p></body></html> 420 | 421 | 422 | Audio only 423 | 424 | 425 | audioVideoButtonGroup 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 10 435 | 436 | 437 | 5 438 | 439 | 440 | 441 | 442 | 443 | Segoe UI Semibold 444 | 10 445 | false 446 | 447 | 448 | 449 | <html><head/><body><p>The <span style=" font-weight:700;">input file</span>. It must be a valid media file supported by ffmpeg.</p><p>If your file does not work, please report a bug on <a href="https://github.com/Thurinum/free-video-compressor/issues"><span style=" text-decoration: underline; color:#007af4;">our issue tracker</span></a>.</p></body></html> 450 | 451 | 452 | Select file to re-encode 453 | 454 | 455 | 456 | 457 | 458 | 459 | <html><head/><body><p>The <span style=" font-weight:700;">input file</span>. It must be a valid media file supported by ffmpeg.</p><p>If your file does not work, please report a bug on <a href="https://github.com/Thurinum/free-video-compressor/issues"><span style=" text-decoration: underline; color:#007af4;">our issue tracker</span></a>.</p></body></html> 460 | 461 | 462 | 463 | 464 | 465 | false 466 | 467 | 468 | Please open a file 469 | 470 | 471 | true 472 | 473 | 474 | 475 | 476 | 477 | 478 | Open... 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 10 488 | 489 | 490 | 5 491 | 492 | 493 | 494 | 495 | 496 | 0 497 | 0 498 | 499 | 500 | 501 | 502 | Segoe UI Semibold 503 | 10 504 | false 505 | 506 | 507 | 508 | Height 509 | 510 | 511 | 512 | 513 | 514 | 515 | <html><head/><body><p>A custom <span style=" font-weight:700;">scale</span>, in pixels, for the output video.</p><p>If a custom aspect ratio is specified, it will apply over it.</p></body></html> 516 | 517 | 518 | Auto 519 | 520 | 521 | px 522 | 523 | 524 | 99999 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 0 533 | 0 534 | 535 | 536 | 537 | 538 | Segoe UI Semibold 539 | 10 540 | false 541 | 542 | 543 | 544 | Width 545 | 546 | 547 | 548 | 549 | 550 | 551 | <html><head/><body><p>A custom <span style=" font-weight:700;">scale</span>, in pixels, for the output video.</p><p>If a custom aspect ratio is specified, it will apply over it.</p></body></html> 552 | 553 | 554 | Auto 555 | 556 | 557 | px 558 | 559 | 560 | 99999 561 | 562 | 563 | 0 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 5 573 | 574 | 575 | 576 | 577 | <html><head/><body><p>The <span style=" font-weight:700;">speed </span>of both video and audio.</p><p>Note that changing the framerate in <span style=" font-style:italic;">Expert mode </span>will affect video speed.</p></body></html> 578 | 579 | 580 | Auto 581 | 582 | 583 | 0.000000000000000 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | Segoe UI Semibold 592 | 10 593 | false 594 | 595 | 596 | 597 | Speed 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 5 607 | 608 | 609 | 610 | 611 | 612 | Segoe UI Semibold 613 | 10 614 | false 615 | 616 | 617 | 618 | <html><head/><body><p>Select a <span style=" font-weight:700;">quality preset </span>for the re-encoded media. This defines the codecs used.</p><p>You can also specify codecs <span style=" font-weight:700;">manually</span> by enabling <span style=" font-style:italic;">Choose codecs manually</span> in <span style=" font-style:italic;">Expert mode</span>.</p></body></html> 619 | 620 | 621 | Apply a quality preset 622 | 623 | 624 | 625 | 626 | 627 | 628 | <html><head/><body><p>Select a <span style=" font-weight:700;">quality preset </span>for the re-encoded media. This defines the codecs used.</p><p>You can also specify codecs <span style=" font-weight:700;">manually</span> by enabling <span style=" font-style:italic;">Choose codecs manually</span> in <span style=" font-style:italic;">Expert mode</span>.</p></body></html> 629 | 630 | 631 | Select preset... 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 10 641 | 642 | 643 | 5 644 | 645 | 646 | 647 | 648 | 649 | Segoe UI Semibold 650 | 10 651 | false 652 | 653 | 654 | 655 | <html><head/><body><p>The path<span style=" font-weight:700;"/>where the resulting encoded media will be output.</p></body></html> 656 | 657 | 658 | Select output folder 659 | 660 | 661 | 662 | 663 | 664 | 665 | <html><head/><body><p>The path<span style=" font-weight:700;"/>where the resulting encoded media will be output.</p></body></html> 666 | 667 | 668 | 669 | 670 | 671 | false 672 | 673 | 674 | Leave empty to use input path 675 | 676 | 677 | true 678 | 679 | 680 | 681 | 682 | 683 | 684 | <html><head/><body><p>The path<span style=" font-weight:700;"/>where the resulting encoded media will be output.</p></body></html> 685 | 686 | 687 | Open... 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | Qt::Orientation::Vertical 697 | 698 | 699 | QSizePolicy::Policy::Expanding 700 | 701 | 702 | 703 | 20 704 | 0 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 18 714 | 715 | 716 | 717 | <html><head/><body><p>This button shows whenever some of the options you have selected are <span style=" font-weight:700;">conflicting.</span></p></body></html> 718 | 719 | 720 | ⚠️ 721 | 722 | 723 | true 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 0 735 | 0 736 | 737 | 738 | 739 | 740 | 16777215 741 | 16777215 742 | 743 | 744 | 745 | 746 | QLayout::SizeConstraint::SetDefaultConstraint 747 | 748 | 749 | 20 750 | 751 | 752 | 0 753 | 754 | 755 | 0 756 | 757 | 758 | 0 759 | 760 | 761 | 20 762 | 763 | 764 | 765 | 766 | 16 767 | 768 | 769 | 2 770 | 771 | 772 | 773 | 774 | 775 | Segoe UI 776 | 9 777 | false 778 | false 779 | 780 | 781 | 782 | Container 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | Segoe UI 791 | 9 792 | false 793 | false 794 | 795 | 796 | 797 | Video Codec 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | Segoe UI 806 | 9 807 | false 808 | false 809 | 810 | 811 | 812 | Audio Codec 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | Segoe UI 821 | 10 822 | false 823 | 824 | 825 | 826 | <html><head/><body><p>The <span style=" font-weight:700;">video codec</span> used. Choosing the right codec has an impact on output quality, compatibility, and compression speed. For example, at equal bitrate, a video encoded in H.265 will have noticeably less artifacts than one encoded with H.264, but it will take longer to encode and may not be supported by every app (Discord as of 2023 does not support H.265). Take note that some codecs may not be available depending on your hardware.</p></body></html> 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | Segoe UI 835 | 10 836 | false 837 | 838 | 839 | 840 | <html><head/><body><p>The <span style=" font-weight:700;">audio codec </span>used. Choosing the right codec has an impact on output quality, compatibility, and compression speed. For example, at equal bitrate, an audio encoded in OPUS will have noticeably better quality than one encoded with MP3, but it will take slightly longer to encode and may not be supported by legacy apps. Take note that some codecs may not be available depending on your hardware.</p><p><br/></p></body></html> 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | Segoe UI 849 | 10 850 | false 851 | 852 | 853 | 854 | <html><head/><body><p>The <span style=" font-weight:700;">container </span>defines the format combining the video and audio codecs.</p><p>Take note that not all contains support all codecs or combinations of codecs!</p><p>If you're unsure, choose mp4.</p></body></html> 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | false 865 | 866 | 867 | 868 | <html><head/><body><p>Display <span style=" font-weight:700;">statistics </span>about the media.</p></body></html> 869 | 870 | 871 | ⓘ Statistics... 872 | 873 | 874 | 875 | 876 | 877 | 878 | 7 879 | 880 | 881 | 5 882 | 883 | 884 | 885 | 886 | 887 | Segoe UI Semibold 888 | 10 889 | false 890 | 891 | 892 | 893 | Aspect ratio 894 | 895 | 896 | 897 | 898 | 899 | 900 | <html><head/><body><p>Sets the <span style=" font-weight:700;">aspect ratio</span>.</p><p>Note that this will override the aspect ratio defined by the <span style=" font-style:italic;">Width </span>and <span style=" font-style:italic;">Height </span>controls.</p></body></html> 901 | 902 | 903 | # 904 | 905 | 906 | 0 907 | 908 | 909 | 0 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | Segoe UI 918 | 12 919 | true 920 | 921 | 922 | 923 | : 924 | 925 | 926 | Qt::AlignmentFlag::AlignCenter 927 | 928 | 929 | 930 | 931 | 932 | 933 | <html><head/><body><p>Sets the <span style=" font-weight:700;">aspect ratio</span>.</p><p>Note that this will override the aspect ratio defined by the <span style=" font-style:italic;">Width </span>and <span style=" font-style:italic;">Height </span>controls.</p></body></html> 934 | 935 | 936 | # 937 | 938 | 939 | 0 940 | 941 | 942 | 0 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 2 952 | 953 | 954 | 955 | 956 | <b>Channels 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 0 965 | 0 966 | 967 | 968 | 969 | 970 | 0 971 | 0 972 | 973 | 974 | 975 | 976 | 0 977 | 0 978 | 979 | 980 | 981 | Auto 982 | 983 | 984 | 0 985 | 986 | 987 | 999 988 | 989 | 990 | 0 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | QLayout::SizeConstraint::SetDefaultConstraint 1000 | 1001 | 1002 | 4 1003 | 1004 | 1005 | 5 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 0 1012 | 0 1013 | 1014 | 1015 | 1016 | 1017 | Segoe UI 1018 | 10 1019 | false 1020 | 1021 | 1022 | 1023 | 128 kbps 1024 | 1025 | 1026 | Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTop|Qt::AlignmentFlag::AlignTrailing 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | Segoe UI 1035 | 10 1036 | false 1037 | 1038 | 1039 | 1040 | <b>Audio quality 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 0 1049 | 0 1050 | 1051 | 1052 | 1053 | <html><head/><body><p>The <span style=" font-weight:700;">constant audio bitrate</span> (kbps). In general, 196kbps is considered decent quality, 128kbps passable quality and anything lower brings very noticeably loss.</p></body></html> 1054 | 1055 | 1056 | 100 1057 | 1058 | 1059 | 1 1060 | 1061 | 1062 | 50 1063 | 1064 | 1065 | Qt::Orientation::Horizontal 1066 | 1067 | 1068 | false 1069 | 1070 | 1071 | QSlider::TickPosition::TicksBelow 1072 | 1073 | 1074 | 25 1075 | 1076 | 1077 | 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 3 1084 | 1085 | 1086 | 5 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | Segoe UI Semibold 1093 | 10 1094 | false 1095 | 1096 | 1097 | 1098 | Desired file size 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 0 1107 | 0 1108 | 1109 | 1110 | 1111 | <html><head/><body><p>Set the <span style=" font-weight:700;">unit</span> used for the desired file size.</p></body></html> 1112 | 1113 | 1114 | 1 1115 | 1116 | 1117 | 1118 | Kilobytes 1119 | 1120 | 1121 | 1122 | 1123 | Megabytes 1124 | 1125 | 1126 | 1127 | 1128 | Gigabytes 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 0 1138 | 0 1139 | 1140 | 1141 | 1142 | <html><head/><body><p>Set the <span style=" font-weight:700;">desired file size</span>. Based on this value, the tool will calculate a <span style=" font-weight:700;">constant video bitrate </span>(CBR)<span style=" font-weight:700;"/>and take audio into account to achieve the specified file size. However, due to the nature of encoding, it cannot guarantee the specified file size will be always accurate.</p><p>If set to <span style=" font-style:italic;">Auto</span>, will let ffmpeg decide.</p></body></html> 1143 | 1144 | 1145 | Auto 1146 | 1147 | 1148 | 0.000000000000000 1149 | 1150 | 1151 | 9999.000000000000000 1152 | 1153 | 1154 | 0.000000000000000 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 5 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | Segoe UI Semibold 1170 | 10 1171 | false 1172 | 1173 | 1174 | 1175 | Frame rate 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | <html><head/><body><p>A custom <span style=" font-weight:700;">video frame rate</span>. Prefer using the <span style=" font-style:italic;">speed</span> control instead.</p></body></html> 1183 | 1184 | 1185 | Auto 1186 | 1187 | 1188 | fps 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 0 1195 | 1196 | 1197 | 999 1198 | 1199 | 1200 | 0 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 5 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | Segoe UI Semibold 1216 | 10 1217 | false 1218 | 1219 | 1220 | 1221 | <html><head/><body><p>For advanced users, this lets you specify a chain of <span style=" font-weight:700;">custom arguments</span> for the ffmpeg process. You may only use valid characters.</p></body></html> 1222 | 1223 | 1224 | Custom command 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 0 1233 | 0 1234 | 1235 | 1236 | 1237 | false 1238 | 1239 | 1240 | <html><head/><body><p>For advanced users, this lets you specify a chain of <span style=" font-weight:700;">custom arguments</span> for the ffmpeg process. You may only use valid characters.</p></body></html> 1241 | 1242 | 1243 | Additional FFMPEG arguments 1244 | 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1 1253 | 1254 | 1255 | QLayout::SizeConstraint::SetMaximumSize 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | Segoe UI Semibold 1262 | 10 1263 | false 1264 | 1265 | 1266 | 1267 | Advanced options 1268 | 1269 | 1270 | Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | Qt::Orientation::Vertical 1278 | 1279 | 1280 | QSizePolicy::Policy::Fixed 1281 | 1282 | 1283 | 1284 | 20 1285 | 4 1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | <html><head/><body><p>Whether only a selection of the most common codecs and containers should be displayed in the dropdowns. Uncheck to use all available codecs from FFmpeg, but note that not all combinations are supported.</p></body></html> 1297 | 1298 | 1299 | Show common formats only 1300 | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | <html><head/><body><p>If checked, you will be warned when the compressed output would <span style=" font-weight:700;">overwrite</span> a file.</p></body></html> 1307 | 1308 | 1309 | Warn when overwriting input file 1310 | 1311 | 1312 | true 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | <html><head/><body><p>If checked, the input media file will be <span style=" font-weight:700;">deleted</span> upon successful compression. Use with care, it won't be recoverable.</p></body></html> 1320 | 1321 | 1322 | Delete input file on success 1323 | 1324 | 1325 | 1326 | 1327 | 1328 | 1329 | <html><head/><body><p>If checked, fields will be <span style=" font-weight:700;">auto-filled </span>when an input file is selected.</p><p>Use with care, it auto-fills everything.</p></body></html> 1330 | 1331 | 1332 | Auto-fill metadata on file selection 1333 | 1334 | 1335 | true 1336 | 1337 | 1338 | 1339 | 1340 | 1341 | 1342 | 1343 | 1344 | 1345 | 0 1346 | 0 1347 | 1348 | 1349 | 1350 | 1351 | 0 1352 | 0 1353 | 1354 | 1355 | 1356 | QFrame::Shadow::Plain 1357 | 1358 | 1359 | 0 1360 | 1361 | 1362 | 1 1363 | 1364 | 1365 | Qt::Orientation::Vertical 1366 | 1367 | 1368 | 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 | Qt::Orientation::Vertical 1379 | 1380 | 1381 | QSizePolicy::Policy::Fixed 1382 | 1383 | 1384 | 1385 | 20 1386 | 10 1387 | 1388 | 1389 | 1390 | 1391 | 1392 | 1393 | 1394 | 1395 | 0 1396 | 1 1397 | 1398 | 1399 | 1400 | 1401 | 0 1402 | 45 1403 | 1404 | 1405 | 1406 | 1407 | Segoe UI 1408 | 14 1409 | 1410 | 1411 | 1412 | Start encoding 1413 | 1414 | 1415 | 1416 | 1417 | 1418 | 1419 | Qt::Orientation::Vertical 1420 | 1421 | 1422 | QSizePolicy::Policy::Fixed 1423 | 1424 | 1425 | 1426 | 20 1427 | 0 1428 | 1429 | 1430 | 1431 | 1432 | 1433 | 1434 | 1435 | 1436 | 0 1437 | 0 1438 | 1439 | 1440 | 1441 | 1442 | 16777215 1443 | 0 1444 | 1445 | 1446 | 1447 | 1448 | 1449 | 1450 | 1451 | 4 1452 | 1453 | 1454 | QLayout::SizeConstraint::SetDefaultConstraint 1455 | 1456 | 1457 | 0 1458 | 1459 | 1460 | 0 1461 | 1462 | 1463 | 0 1464 | 1465 | 1466 | 0 1467 | 1468 | 1469 | 1470 | 1471 | 0 1472 | 1473 | 1474 | Qt::AlignmentFlag::AlignCenter 1475 | 1476 | 1477 | 1478 | 1479 | 1480 | 1481 | 1482 | 1483 | 1484 | Qt::AlignmentFlag::AlignCenter 1485 | 1486 | 1487 | 1488 | 1489 | 1490 | 1491 | 1492 | 1493 | 1494 | 1495 | advancedModeCheckBox 1496 | infoMenuToolButton 1497 | inputFileLineEdit 1498 | inputFileButton 1499 | radVideoAudio 1500 | radVideoOnly 1501 | radAudioOnly 1502 | outputFileNameLineEdit 1503 | outputFileNameSuffixCheckBox 1504 | outputFolderLineEdit 1505 | outputFolderButton 1506 | qualityPresetComboBox 1507 | widthSpinBox 1508 | heightSpinBox 1509 | speedSpinBox 1510 | openExplorerOnSuccessCheckBox 1511 | playOnSuccessCheckBox 1512 | closeOnSuccessCheckBox 1513 | videoCodecComboBox 1514 | audioCodecComboBox 1515 | containerComboBox 1516 | audioQualitySlider 1517 | fileSizeSpinBox 1518 | fileSizeUnitComboBox 1519 | aspectRatioSpinBoxH 1520 | aspectRatioSpinBoxV 1521 | fpsSpinBox 1522 | customCommandTextEdit 1523 | warnOnOverwriteCheckBox 1524 | deleteOnSuccessCheckBox 1525 | autoFillCheckBox 1526 | statisticsButton 1527 | warningTooltipButton 1528 | startCompressionButton 1529 | 1530 | 1531 | 1532 | 1533 | advancedModeCheckBox 1534 | clicked(bool) 1535 | MainWindow 1536 | SetAdvancedMode(bool) 1537 | 1538 | 1539 | 835 1540 | 43 1541 | 1542 | 1543 | 526 1544 | 614 1545 | 1546 | 1547 | 1548 | 1549 | startCompressionButton 1550 | clicked() 1551 | MainWindow 1552 | StartEncoding() 1553 | 1554 | 1555 | 315 1556 | 671 1557 | 1558 | 1559 | 301 1560 | 617 1561 | 1562 | 1563 | 1564 | 1565 | widthSpinBox 1566 | valueChanged(int) 1567 | MainWindow 1568 | CheckAspectRatioConflict() 1569 | 1570 | 1571 | 258 1572 | 348 1573 | 1574 | 1575 | 167 1576 | 614 1577 | 1578 | 1579 | 1580 | 1581 | heightSpinBox 1582 | valueChanged(int) 1583 | MainWindow 1584 | CheckAspectRatioConflict() 1585 | 1586 | 1587 | 337 1588 | 348 1589 | 1590 | 1591 | 241 1592 | 611 1593 | 1594 | 1595 | 1596 | 1597 | aspectRatioSpinBoxH 1598 | valueChanged(int) 1599 | MainWindow 1600 | CheckAspectRatioConflict() 1601 | 1602 | 1603 | 721 1604 | 239 1605 | 1606 | 1607 | 598 1608 | 607 1609 | 1610 | 1611 | 1612 | 1613 | aspectRatioSpinBoxV 1614 | valueChanged(int) 1615 | MainWindow 1616 | CheckAspectRatioConflict() 1617 | 1618 | 1619 | 774 1620 | 239 1621 | 1622 | 1623 | 761 1624 | 607 1625 | 1626 | 1627 | 1628 | 1629 | speedSpinBox 1630 | valueChanged(double) 1631 | MainWindow 1632 | CheckSpeedConflict() 1633 | 1634 | 1635 | 411 1636 | 348 1637 | 1638 | 1639 | 396 1640 | 612 1641 | 1642 | 1643 | 1644 | 1645 | fpsSpinBox 1646 | valueChanged(int) 1647 | MainWindow 1648 | CheckSpeedConflict() 1649 | 1650 | 1651 | 860 1652 | 240 1653 | 1654 | 1655 | 798 1656 | 605 1657 | 1658 | 1659 | 1660 | 1661 | outputFolderButton 1662 | clicked() 1663 | MainWindow 1664 | SelectOutputDirectory() 1665 | 1666 | 1667 | 411 1668 | 282 1669 | 1670 | 1671 | 433 1672 | 6 1673 | 1674 | 1675 | 1676 | 1677 | audioQualitySlider 1678 | valueChanged(int) 1679 | MainWindow 1680 | UpdateAudioQualityLabel(int) 1681 | 1682 | 1683 | 718 1684 | 173 1685 | 1686 | 1687 | 890 1688 | 611 1689 | 1690 | 1691 | 1692 | 1693 | statisticsButton 1694 | clicked() 1695 | MainWindow 1696 | ShowMetadata() 1697 | 1698 | 1699 | 775 1700 | 522 1701 | 1702 | 1703 | 890 1704 | 563 1705 | 1706 | 1707 | 1708 | 1709 | inputFileButton 1710 | clicked() 1711 | MainWindow 1712 | OpenInputFile() 1713 | 1714 | 1715 | 411 1716 | 114 1717 | 1718 | 1719 | 397 1720 | 13 1721 | 1722 | 1723 | 1724 | 1725 | audioVideoButtonGroup 1726 | buttonClicked(QAbstractButton*) 1727 | MainWindow 1728 | UpdateControlsState() 1729 | 1730 | 1731 | -1 1732 | -1 1733 | 1734 | 1735 | 461 1736 | 309 1737 | 1738 | 1739 | 1740 | 1741 | infoMenuToolButton 1742 | pressed() 1743 | infoMenuToolButton 1744 | showMenu() 1745 | 1746 | 1747 | 870 1748 | 44 1749 | 1750 | 1751 | 870 1752 | 44 1753 | 1754 | 1755 | 1756 | 1757 | qualityPresetComboBox 1758 | currentIndexChanged(int) 1759 | MainWindow 1760 | LoadPreset(int) 1761 | 1762 | 1763 | 97 1764 | 342 1765 | 1766 | 1767 | 13 1768 | 549 1769 | 1770 | 1771 | 1772 | 1773 | commonFormatsOnlyCheckbox 1774 | toggled(bool) 1775 | MainWindow 1776 | UpdateCodecsList(bool) 1777 | 1778 | 1779 | 665 1780 | 543 1781 | 1782 | 1783 | 890 1784 | 478 1785 | 1786 | 1787 | 1788 | 1789 | videoCodecComboBox 1790 | activated(int) 1791 | MainWindow 1792 | SelectVideoCodec(int) 1793 | 1794 | 1795 | 580 1796 | 108 1797 | 1798 | 1799 | 890 1800 | 396 1801 | 1802 | 1803 | 1804 | 1805 | audioCodecComboBox 1806 | activated(int) 1807 | MainWindow 1808 | SelectAudioCodec(int) 1809 | 1810 | 1811 | 720 1812 | 108 1813 | 1814 | 1815 | 890 1816 | 352 1817 | 1818 | 1819 | 1820 | 1821 | 1822 | SetAdvancedMode(bool) 1823 | StartEncoding() 1824 | CheckAspectRatioConflict() 1825 | SelectPresetCodecs() 1826 | CheckSpeedConflict() 1827 | SelectOutputDirectory() 1828 | UpdateAudioQualityLabel(int) 1829 | UpdateControlsState() 1830 | SetAllowPresetSelection(bool) 1831 | ShowMetadata() 1832 | OpenInputFile() 1833 | LoadPreset(int) 1834 | UpdateCodecsList(bool) 1835 | SelectVideoCodec(int) 1836 | SelectAudioCodec(int) 1837 | SelectContainer(int) 1838 | 1839 | 1840 | 1841 | 1842 | 1843 | --------------------------------------------------------------------------------