├── .github
├── pre-commit
│ ├── ignored-words.txt
│ └── config.yaml
└── workflows
│ ├── lint.yaml
│ └── ci.yml
├── img
├── cut_video.png
├── info_view.png
└── compress_picture.png
├── src
├── resources
│ ├── lang_chinese.qm
│ ├── OpenConverter.icns
│ ├── OpenConverter-logo.png
│ └── lang.qrc
├── common
│ ├── include
│ │ ├── process_observer.h
│ │ ├── stream_context.h
│ │ ├── process_parameter.h
│ │ ├── info.h
│ │ └── encode_parameter.h
│ └── src
│ │ ├── stream_context.cpp
│ │ ├── process_parameter.cpp
│ │ ├── encode_parameter.cpp
│ │ └── info.cpp
├── builder
│ ├── include
│ │ ├── placeholder_page.h
│ │ ├── shared_data.h
│ │ ├── transcoder_helper.h
│ │ ├── base_page.h
│ │ ├── create_gif_page.h
│ │ ├── batch_file_dialog.h
│ │ ├── info_view_page.h
│ │ ├── extract_audio_page.h
│ │ ├── compress_picture_page.h
│ │ ├── batch_queue.h
│ │ ├── batch_item.h
│ │ ├── remux_page.h
│ │ ├── batch_queue_dialog.h
│ │ ├── transcode_page.h
│ │ ├── cut_video_page.h
│ │ ├── open_converter.h
│ │ ├── batch_mode_helper.h
│ │ └── converter_runner.h
│ └── src
│ │ ├── transcoder_helper.cpp
│ │ ├── placeholder_page.cpp
│ │ ├── shared_data.cpp
│ │ ├── base_page.cpp
│ │ ├── batch_item.cpp
│ │ ├── batch_queue.cpp
│ │ └── batch_mode_helper.cpp
├── tests
│ └── CMakeLists.txt
├── engine
│ ├── include
│ │ └── converter.h
│ └── src
│ │ └── converter.cpp
├── transcoder
│ ├── include
│ │ ├── transcoder_bmf.h
│ │ ├── transcoder_fftool.h
│ │ ├── transcoder_ffmpeg.h
│ │ └── transcoder.h
│ └── src
│ │ └── transcoder_bmf.cpp
└── component
│ ├── src
│ ├── progress_widget.cpp
│ ├── quality_widget.cpp
│ ├── bitrate_widget.cpp
│ ├── codec_selector_widget.cpp
│ ├── pixel_format_widget.cpp
│ ├── resolution_widget.cpp
│ └── format_selector_widget.cpp
│ └── include
│ ├── quality_widget.h
│ ├── bitrate_widget.h
│ ├── pixel_format_widget.h
│ ├── simple_video_player.h
│ ├── codec_selector_widget.h
│ ├── resolution_widget.h
│ ├── progress_widget.h
│ ├── format_selector_widget.h
│ ├── batch_input_widget.h
│ ├── filter_tag_widget.h
│ ├── batch_output_widget.h
│ └── file_selector_widget.h
├── .gitmodules
├── .clang-format
├── .gitignore
├── doc
├── Qt.md
├── OpenConverter_Deploy.md
├── OpenConverter_Usage.md
└── CompileGuide.md
├── tool
├── fix_whitespace.sh
├── setup_test_deps.sh
├── format.sh
├── dmg_install_instructions.txt
├── fix_gatekeeper.sh
├── build_and_package_macos.sh
└── create_dmg_simple.sh
├── CONTRIBUTING.md
└── README_ZH.md
/.github/pre-commit/ignored-words.txt:
--------------------------------------------------------------------------------
1 | anull
2 | bmf
3 | BMF
4 |
--------------------------------------------------------------------------------
/img/cut_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenConverterLab/OpenConverter/HEAD/img/cut_video.png
--------------------------------------------------------------------------------
/img/info_view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenConverterLab/OpenConverter/HEAD/img/info_view.png
--------------------------------------------------------------------------------
/img/compress_picture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenConverterLab/OpenConverter/HEAD/img/compress_picture.png
--------------------------------------------------------------------------------
/src/resources/lang_chinese.qm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenConverterLab/OpenConverter/HEAD/src/resources/lang_chinese.qm
--------------------------------------------------------------------------------
/src/resources/OpenConverter.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenConverterLab/OpenConverter/HEAD/src/resources/OpenConverter.icns
--------------------------------------------------------------------------------
/src/resources/OpenConverter-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenConverterLab/OpenConverter/HEAD/src/resources/OpenConverter-logo.png
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "3rd_party/gtest"]
2 | path = 3rd_party/gtest
3 | url = https://github.com/google/googletest.git
4 | ignore = dirty
5 |
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: LLVM
2 | AccessModifierOffset: -4
3 | IndentWidth: 4
4 | IndentPPDirectives: BeforeHash
5 | IndentAccessModifiers: false
6 |
--------------------------------------------------------------------------------
/src/resources/lang.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | lang_chinese.qm
4 | OpenConverter-logo.png
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | open_converter.pro.user
2 | build-*
3 | .vscode
4 | .DS_Store
5 | ./src/.DS_Store
6 | src/CMakeLists.txt.user
7 | src/build
8 | src/build-*
9 | build
10 | .idea
11 | workload_output.txt
12 |
--------------------------------------------------------------------------------
/doc/Qt.md:
--------------------------------------------------------------------------------
1 | # [Qt](https://www.qt.io)介绍
2 |
3 | Qt是一种跨平台的C++应用程序开发框架,由Qt公司(位于挪威和德国)开发。Qt可以用于开发图形用户界面(GUI)程序、命令行工具、服务器端应用程序等多种类型的软件。
4 |
5 | Qt提供了丰富的类库和工具集,使得开发者能够轻松地创建高质量的应用程序。Qt还支持多种操作系统和硬件平台,包括Windows、Linux、macOS、Android等。
6 |
7 | ## Qt的主要特点包括:
8 |
9 | * 跨平台支持:Qt支持多种操作系统和硬件平台,并提供相应的API和工具集。
10 |
11 | * 面向对象设计:Qt基于面向对象的设计思想,提供丰富的类库和模块,使开发者能够快速构建高质量的应用程序。
12 |
13 | * 可扩展性:Qt提供了多种扩展方式,包括插件、组件等,方便开发者进行功能扩展和定制化。
14 |
15 | * 易于学习和使用:Qt的API设计符合直觉,易于理解和记忆,同时也提供了详细的文档和教程,帮助开发者快速上手。
16 |
17 | ## Qt相关网站
18 |
19 | [Qt官方网站](https://www.qt.io/)
20 |
21 | [Qt中文网站](https://www.qtchina.net/)
22 |
23 | [Qt文档](https://doc.qt.io/)
24 |
25 | [Qt论坛](https://forum.qt.io/)
26 |
27 | ## 本项目所使用Qt版本
28 |
29 | 5.14.2
30 |
--------------------------------------------------------------------------------
/.github/pre-commit/config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/pre-commit/pre-commit-hooks
3 | rev: v5.0.0
4 | hooks:
5 | - id: check-case-conflict
6 | - id: check-executables-have-shebangs
7 | - id: check-illegal-windows-names
8 | - id: check-yaml
9 | - id: end-of-file-fixer
10 | - id: file-contents-sorter
11 | files:
12 | .github/pre-commit/ignored-words.txt
13 | args:
14 | - --ignore-case
15 | - id: fix-byte-order-marker
16 | - id: mixed-line-ending
17 | - id: trailing-whitespace
18 | - repo: https://github.com/codespell-project/codespell
19 | rev: v2.4.1
20 | hooks:
21 | - id: codespell
22 | args:
23 | - --ignore-words=.github/pre-commit/ignored-words.txt
24 | - --ignore-multiline-regex=codespell:off.*?(codespell:on|\Z)
25 | exclude: ^tools/(patcheck|clean-diff)$
26 |
--------------------------------------------------------------------------------
/src/common/include/process_observer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #ifndef PROCESSOBSERVER_H
19 | #define PROCESSOBSERVER_H
20 |
21 | class ProcessObserver {
22 | public:
23 | virtual ~ProcessObserver() = default;
24 | virtual void on_process_update(double progress) = 0;
25 | virtual void on_time_update(double timeRequired) = 0;
26 | };
27 |
28 | #endif // PROCESSOBSERVER_H
29 |
--------------------------------------------------------------------------------
/tool/fix_whitespace.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Fix trailing whitespace and ensure single newline at end of file
3 |
4 | # Get list of staged files (C++ and header files)
5 | files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cpp|h|hpp|cc|cxx)$')
6 |
7 | if [ -z "$files" ]; then
8 | echo "No C++ files to fix"
9 | exit 0
10 | fi
11 |
12 | echo "Fixing whitespace issues in files..."
13 | echo ""
14 |
15 | for file in $files; do
16 | if [ -f "$file" ]; then
17 | echo " $file"
18 |
19 | # Remove trailing whitespace from each line
20 | sed -i '' 's/[[:space:]]*$//' "$file"
21 |
22 | # Ensure file ends with exactly one newline
23 | # This perl command ensures the file ends with exactly one newline
24 | perl -pi -e 'BEGIN{undef $/;} s/\s*\z/\n/' "$file"
25 | fi
26 | done
27 |
28 | echo ""
29 | echo "Done! Fixed whitespace in $(echo "$files" | wc -l | tr -d ' ') files"
30 | echo ""
31 | echo "⚠️ Please review the changes and add them manually:"
32 | echo " git add "
33 | echo " or: git add -u"
34 |
--------------------------------------------------------------------------------
/.github/workflows/lint.yaml:
--------------------------------------------------------------------------------
1 | name: lint
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | pull_request:
7 | branches: [ main ]
8 | workflow_dispatch:
9 |
10 | jobs:
11 | lint:
12 | permissions:
13 | contents: read
14 | runs-on: ubuntu-22.04
15 | steps:
16 | - name: Checkout
17 | uses: actions/checkout@v4
18 | - name: Install pre-commit CI
19 | id: install
20 | run: |
21 | python3 -m venv ~/pre-commit
22 | ~/pre-commit/bin/pip install --upgrade pip setuptools
23 | ~/pre-commit/bin/pip install pre-commit
24 | echo "envhash=$({ python3 --version && cat .github/pre-commit/config.yaml; } | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
25 | - name: Cache
26 | uses: actions/cache@v4
27 | with:
28 | path: ~/.cache/pre-commit
29 | key: pre-commit-${{ steps.install.outputs.envhash }}
30 | - name: Run pre-commit CI
31 | run: ~/pre-commit/bin/pre-commit run -c .github/pre-commit/config.yaml --show-diff-on-failure --color=always --all-files
32 |
--------------------------------------------------------------------------------
/src/builder/include/placeholder_page.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #ifndef PLACEHOLDER_PAGE_H
19 | #define PLACEHOLDER_PAGE_H
20 |
21 | #include "base_page.h"
22 | #include
23 | #include
24 |
25 | class PlaceholderPage : public BasePage {
26 | Q_OBJECT
27 |
28 | public:
29 | explicit PlaceholderPage(const QString &title, QWidget *parent = nullptr);
30 | ~PlaceholderPage();
31 |
32 | QString GetPageTitle() const override;
33 |
34 | private:
35 | QString pageTitle;
36 | QLabel *label;
37 | };
38 |
39 | #endif // PLACEHOLDER_PAGE_H
40 |
--------------------------------------------------------------------------------
/src/builder/src/transcoder_helper.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #include "../include/transcoder_helper.h"
19 | #include "../include/open_converter.h"
20 | #include
21 |
22 | QString TranscoderHelper::GetCurrentTranscoderName(QWidget *widget) {
23 | if (!widget) {
24 | return "FFMPEG"; // Default fallback
25 | }
26 |
27 | // Get main window
28 | OpenConverter *mainWindow = qobject_cast(widget->window());
29 | if (mainWindow) {
30 | return mainWindow->GetCurrentTranscoderName();
31 | }
32 |
33 | // Fallback to default
34 | return "FFMPEG";
35 | }
36 |
--------------------------------------------------------------------------------
/src/builder/src/placeholder_page.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #include "../include/placeholder_page.h"
19 |
20 | PlaceholderPage::PlaceholderPage(const QString &title, QWidget *parent)
21 | : BasePage(parent), pageTitle(title) {
22 | QVBoxLayout *layout = new QVBoxLayout(this);
23 |
24 | label = new QLabel(QString("Page: %1\n\nThis page will be implemented later.").arg(title), this);
25 | label->setAlignment(Qt::AlignCenter);
26 | label->setStyleSheet("font-size: 16px; color: #666;");
27 |
28 | layout->addWidget(label);
29 | setLayout(layout);
30 | }
31 |
32 | PlaceholderPage::~PlaceholderPage() {}
33 |
34 | QString PlaceholderPage::GetPageTitle() const {
35 | return pageTitle;
36 | }
37 |
--------------------------------------------------------------------------------
/tool/setup_test_deps.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Exit on error
4 | set -e
5 |
6 | # Get the root directory of the project
7 | ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8 | THIRD_PARTY_DIR="${ROOT_DIR}/third_party"
9 |
10 | # Create third_party directory if it doesn't exist
11 | mkdir -p "${THIRD_PARTY_DIR}"
12 |
13 | # Deinitialize all submodules first
14 | echo "Deinitializing existing submodules..."
15 | git submodule deinit -f --all || true
16 |
17 | # Remove .gitmodules if it exists
18 | if [ -f "${ROOT_DIR}/.gitmodules" ]; then
19 | echo "Removing existing .gitmodules..."
20 | rm "${ROOT_DIR}/.gitmodules"
21 | fi
22 |
23 | # Create fresh .gitmodules
24 | echo "Creating new .gitmodules file..."
25 | touch "${ROOT_DIR}/.gitmodules"
26 | git add "${ROOT_DIR}/.gitmodules"
27 |
28 | # Initialize git submodules
29 | echo "Initializing git submodules..."
30 | # git submodule init
31 |
32 | # Add or update googletest submodule
33 | if [ ! -d "${THIRD_PARTY_DIR}/googletest" ]; then
34 | echo "Adding googletest submodule..."
35 | git submodule add https://github.com/google/googletest.git "${THIRD_PARTY_DIR}/googletest"
36 | # git submodule update --init --recursive "${THIRD_PARTY_DIR}/googletest"
37 | (cd "${THIRD_PARTY_DIR}/googletest" && git checkout release-1.12.1)
38 | fi
39 |
40 | echo "Test dependencies have been set up successfully!"
41 |
--------------------------------------------------------------------------------
/src/common/include/stream_context.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * This file is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This file is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | */
15 |
16 | #ifndef STREAMCONTEXT_H
17 | #define STREAMCONTEXT_H
18 |
19 | extern "C" {
20 | #include
21 | #include
22 | #include
23 | };
24 |
25 | #define OC_INVALID_STREAM_IDX -1
26 |
27 | class StreamContext {
28 |
29 | public:
30 | StreamContext();
31 | ~StreamContext();
32 |
33 | AVFormatContext *fmtCtx;
34 | const char *filename;
35 |
36 | int videoIdx;
37 | AVStream *videoStream;
38 | const AVCodec *videoCodec;
39 | AVCodecContext *videoCodecCtx;
40 |
41 | int audioIdx;
42 | AVStream *audioStream;
43 | const AVCodec *audioCodec;
44 | AVCodecContext *audioCodecCtx;
45 |
46 | AVPacket *pkt;
47 | AVFrame *frame;
48 | };
49 |
50 | #endif // STREAMCONTEXT_H
51 |
--------------------------------------------------------------------------------
/src/tests/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 |
3 | # Enable testing
4 | enable_testing()
5 |
6 | # Add GTest from 3rd_party
7 | add_subdirectory(${CMAKE_SOURCE_DIR}/../3rd_party/gtest ${CMAKE_BINARY_DIR}/gtest)
8 |
9 | # Add test executable
10 | add_executable(transcoder_test transcoder_test.cpp)
11 |
12 | # Set C++17 for std::filesystem
13 | target_compile_features(transcoder_test PRIVATE cxx_std_17)
14 | target_compile_definitions(transcoder_test PRIVATE
15 | _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
16 | GTEST_HAS_PTHREAD=1
17 | TEST_MEDIA_PATH="${CMAKE_BINARY_DIR}/tests/media"
18 | )
19 |
20 | # Include directories
21 | target_include_directories(transcoder_test PRIVATE
22 | ${CMAKE_SOURCE_DIR}/common/include
23 | ${CMAKE_SOURCE_DIR}/transcoder/include
24 | ${CMAKE_SOURCE_DIR}/engine/include
25 | )
26 |
27 | # Link against GTest and core library
28 | target_link_libraries(transcoder_test
29 | PRIVATE
30 | gtest_main
31 | OpenConverterCore
32 | )
33 |
34 | # Copy GTest libraries to test directory
35 | add_custom_command(TARGET transcoder_test POST_BUILD
36 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
37 | $
38 | $
39 | $
40 | $
41 | $
42 | )
43 |
44 | # Add test to CTest
45 | add_test(NAME transcoder_test COMMAND transcoder_test)
46 |
--------------------------------------------------------------------------------
/src/engine/include/converter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #ifndef CONVERTER_H
19 | #define CONVERTER_H
20 |
21 | #include "../../common/include/encode_parameter.h"
22 | #include "../../transcoder/include/transcoder.h"
23 | #include
24 | #include
25 |
26 | class Converter {
27 | public:
28 | Converter();
29 | Converter(ProcessParameter *processParamter,
30 | EncodeParameter *encodeParamter);
31 | ~Converter();
32 |
33 | bool set_transcoder(std::string transcoderName);
34 | bool convert_format(const std::string &src, const std::string &dst);
35 |
36 | private:
37 | Transcoder *transcoder = NULL;
38 | bool copyVideo;
39 | bool copyAudio;
40 |
41 | public:
42 | ProcessParameter *processParameter = NULL;
43 | EncodeParameter *encodeParameter = NULL;
44 | };
45 |
46 | #endif // CONVERTER_H
47 |
--------------------------------------------------------------------------------
/src/common/src/stream_context.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * This file is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This file is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | */
15 |
16 | #include "../include/stream_context.h"
17 |
18 | StreamContext::StreamContext() {
19 | fmtCtx = NULL;
20 | filename = NULL;
21 |
22 | videoIdx = OC_INVALID_STREAM_IDX;
23 | videoStream = NULL;
24 | videoCodec = NULL;
25 | videoCodecCtx = NULL;
26 |
27 | audioIdx = OC_INVALID_STREAM_IDX;
28 | audioStream = NULL;
29 | audioCodec = NULL;
30 | audioCodecCtx = NULL;
31 |
32 | pkt = NULL;
33 | frame = NULL;
34 | }
35 |
36 | StreamContext::~StreamContext() {
37 | if (videoCodecCtx) {
38 | avcodec_free_context(&videoCodecCtx);
39 | videoCodecCtx = NULL;
40 | }
41 | if (audioCodecCtx) {
42 | avcodec_free_context(&audioCodecCtx);
43 | audioCodecCtx = NULL;
44 | }
45 | if (pkt) {
46 | av_packet_free(&pkt);
47 | pkt = NULL;
48 | }
49 | if (frame) {
50 | av_frame_free(&frame);
51 | frame = NULL;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/transcoder/include/transcoder_bmf.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * This file is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This file is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | */
15 |
16 | #ifndef TRANSCODER_BMF_H
17 | #define TRANSCODER_BMF_H
18 |
19 | #include "transcoder.h"
20 |
21 | #include "builder.hpp"
22 | #include "nlohmann/json.hpp"
23 |
24 | #include
25 |
26 | class TranscoderBMF : public Transcoder {
27 | public:
28 | TranscoderBMF(ProcessParameter *process_parameter,
29 | EncodeParameter *encode_parameter);
30 |
31 | bool prepare_info(std::string input_path, std::string output_path);
32 |
33 | bool transcode(std::string input_path, std::string output_path);
34 |
35 | bmf_sdk::CBytes decoder_callback(bmf_sdk::CBytes input);
36 |
37 | bmf_sdk::CBytes encoder_callback(bmf_sdk::CBytes input);
38 |
39 | private:
40 | // encoder's parameters
41 | bool copy_video;
42 | bool copy_audio;
43 |
44 | int width;
45 | int height;
46 |
47 | nlohmann::json decoder_para;
48 | nlohmann::json encoder_para;
49 | };
50 |
51 | #endif // TRANSCODER_BMF_H
52 |
--------------------------------------------------------------------------------
/src/common/include/process_parameter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #ifndef PROCESSPARAMETER_H
19 | #define PROCESSPARAMETER_H
20 |
21 | #include "process_observer.h"
22 | #include
23 | #include
24 |
25 | class ProcessParameter {
26 | public:
27 | ProcessParameter();
28 | ~ProcessParameter();
29 |
30 | void set_process_number(int64_t frameNumber, int64_t frameTotalNumnber);
31 | void set_process_number(int64_t processNumber);
32 | double get_process_number();
33 | void set_time_required(double timeRequired);
34 | double get_time_required();
35 | ProcessParameter get_process_parmeter();
36 |
37 | // Observer management
38 | void add_observer(ProcessObserver* observer);
39 | void remove_observer(ProcessObserver* observer);
40 |
41 | private:
42 | int64_t processNumber;
43 | double timeRequired;
44 | std::vector observers;
45 |
46 | void notify_process_update(double progress);
47 | void notify_time_update(double timeRequired);
48 | };
49 |
50 | #endif // PROCESSPARAMETER_H
51 |
--------------------------------------------------------------------------------
/doc/OpenConverter_Deploy.md:
--------------------------------------------------------------------------------
1 | # Deploy the OpenConverter for Windows Users
2 |
3 | ## 1. Run in Release Mode
4 | - Click the computer icon on the left side of Qt.
5 | - Select "Release."
6 | - Click "Run" to build the project.
7 |
8 | ## 2. Locate the Release Folder
9 | - After the build completes, navigate to the "build" folder.
10 | - Find the "Release" folder containing the packaged files.
11 |
12 | ## 3. Open Qt MinGW Terminal
13 |
14 | - Go to the Start menu.
15 | - Search for "min."
16 | - Select "Qt MinGW" to open the terminal.
17 |
18 | ## 4. Deploy Dependencies with windeployqt
19 | - Copy the path to the folder containing the newly generated .exe file.
20 | - In the terminal:
21 | - Type `windeployqt`.
22 | - Paste the path (Ctrl+V).
23 | - Append a backslash (`\`) followed by the .exe file name.
24 | - Press Enter to execute.
25 |
26 | ## 5. Download Enigma Protector
27 | - Use a new software tool for advanced packaging.
28 | - Download it from: [https://enigmaprotector.com/en/downloads.html](https://enigmaprotector.com/en/downloads.html).
29 |
30 | ## 6. Package the .exe with Enigma Protector
31 | - Use the "Release" folder from the previous step as the base.
32 | - Load the generated .exe file into the software.
33 | - The software will automatically create a new file named `originalname_boxed.exe`.
34 |
35 | ## 7. Configure and Compress
36 | - In the bottom left corner, click "Add."
37 | - Select "Select Folder (Recursive)."
38 | - Under "File Options":
39 | - Check the "Compress Files" box.
40 | - Proceed with the packaging process.
41 |
42 | ## 8. Create Final Archive
43 |
44 | - Combine the packaged .exe file with the DLL files from FFmpeg’s "bin" directory.
45 | - Create a single compressed archive (e.g., ZIP file).
46 |
--------------------------------------------------------------------------------
/src/transcoder/include/transcoder_fftool.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * This file is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This file is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | */
15 |
16 | #ifndef TRANSCODERFFTOOL_H
17 | #define TRANSCODERFFTOOL_H
18 |
19 | #include "transcoder.h"
20 |
21 | class TranscoderFFTool : public Transcoder {
22 | public:
23 | TranscoderFFTool(ProcessParameter *process_parameter,
24 | EncodeParameter *encode_parameter);
25 | ~TranscoderFFTool();
26 |
27 | bool prepared_opt();
28 |
29 | bool transcode(std::string input_path, std::string output_path);
30 |
31 | private:
32 | // encoder's parameters
33 | bool copy_video;
34 | bool copy_audio;
35 |
36 | std::string video_codec;
37 | int64_t video_bit_rate;
38 | std::string audio_codec;
39 | int64_t audio_bit_rate;
40 |
41 | // Additional video parameters
42 | uint16_t width;
43 | uint16_t height;
44 | int qscale;
45 | std::string pixel_format;
46 |
47 | // Time range parameters
48 | double start_time; // in seconds
49 | double end_time; // in seconds
50 |
51 | static int frame_number;
52 |
53 | int64_t frame_total_number;
54 | };
55 |
56 | #endif // TRANSCODERFFTOOL_H
57 |
--------------------------------------------------------------------------------
/doc/OpenConverter_Usage.md:
--------------------------------------------------------------------------------
1 | # OpenConverter Usage Guide for macOS Users
2 |
3 | Thank you for downloading **OpenConverter**! Please follow the steps below to resolve any issues if the app does not open after transferring it out of the DMG file.
4 |
5 | ---
6 |
7 | ## Steps to Fix Opening Issues
8 |
9 | 1. **Download and Transfer the App:**
10 | - Download the OpenConverter DMG file.
11 | - Open the DMG and drag the **OpenConverter.app** to your preferred folder, such as the Applications folder.
12 |
13 | 2. **Resolve Gatekeeper Restrictions:**
14 | If macOS prevents the app from opening due to an unidentified developer error, you need to bypass Apple's Gatekeeper restrictions.
15 |
16 | 3. **Open Terminal:**
17 | - Open the **Terminal** app from your macOS utilities.
18 |
19 | 4. **Run the Following Commands:**
20 |
21 | - Remove the quarantine attribute:
22 | ```bash
23 | sudo xattr -r -d com.apple.quarantine OpenConverter.app
24 | ```
25 | This command removes the quarantine flag set by macOS for apps downloaded from the internet.
26 |
27 | - Re-sign the app:
28 | ```bash
29 | codesign --force --deep --sign - OpenConverter.app
30 | ```
31 | This command ensures that macOS recognizes the app as valid, even without a registered developer signature.
32 |
33 | 5. **Open the App:**
34 | - Double-click **OpenConverter.app** to launch it.
35 | - If macOS prompts for confirmation, click **Open**.
36 |
37 | ---
38 |
39 | ## Note
40 | - These commands require administrative privileges. You will be asked to enter your macOS password when running `sudo`.
41 | - If you experience any further issues, feel free to contact us through the project's repository or support channel.
42 |
43 | Enjoy using **OpenConverter**! 🎉
44 |
--------------------------------------------------------------------------------
/tool/format.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | TOP_DIR=$PWD
3 |
4 | # Define the directories to process
5 | DIRECTORIES=("$TOP_DIR/src")
6 |
7 | # Check if a .clang-format file exists in the current directory. If not, create one.
8 | if [ ! -f "$TOP_DIR/.clang-format" ]; then
9 | echo "No .clang-format file found in $TOP_DIR. Creating a temporary one..."
10 | echo "BasedOnStyle: LLVM" > "$TOP_DIR/.clang-format"
11 | echo "IndentWidth: 4" >> "$TOP_DIR/.clang-format"
12 | echo "AccessModifierOffset: -4" >> "$TOP_DIR/.clang-format"
13 | echo "IndentPPDirectives: BeforeHash" >> "$TOP_DIR/.clang-format"
14 | echo "IndentAccessModifiers: false" >> "$TOP_DIR/.clang-format"
15 | fi
16 |
17 | # Iterate through the specified directories and format the files
18 | for dir in "${DIRECTORIES[@]}"; do
19 | echo "Formatting directory: $dir"
20 | FORMATTED_FILES=()
21 |
22 | # Find all .cpp, .c, .h files in the directory
23 | FILES=$(find "$dir" -type f \( -name "*.cpp" -o -name "*.c" -o -name "*.h" \) -print0)
24 |
25 | # Check if any files were found
26 | if [ -z "$FILES" ]; then
27 | echo "No files found with supported extensions in $dir."
28 | continue
29 | fi
30 |
31 | # Use a while loop to process each file (using null characters as separators)
32 | while IFS= read -r -d '' file; do
33 | clang-format -style=file -i "$file"
34 | FORMATTED_FILES+=("$file")
35 | done < <(find "$dir" -type f \( -name "*.cpp" -o -name "*.c" -o -name "*.h" \) -print0)
36 |
37 | # Output the list of formatted files
38 | if [ ${#FORMATTED_FILES[@]} -gt 0 ]; then
39 | printf "\nFormatted files in %s:\n" "$dir"
40 | printf "%s\n" "${FORMATTED_FILES[@]}"
41 | fi
42 | done
43 |
44 | echo "Formatting completed."
45 |
--------------------------------------------------------------------------------
/src/builder/include/shared_data.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #ifndef SHARED_DATA_H
19 | #define SHARED_DATA_H
20 |
21 | #include
22 |
23 | class SharedData {
24 | public:
25 | SharedData();
26 | ~SharedData();
27 |
28 | // Input file path
29 | QString GetInputFilePath() const;
30 | void SetInputFilePath(const QString &filePath);
31 |
32 | // Output file path
33 | QString GetOutputFilePath() const;
34 | void SetOutputFilePath(const QString &filePath);
35 |
36 | // Generate output path from input path and extension
37 | // If user has manually set output path, returns that
38 | // Otherwise, generates: /path/to/input-oc-output.ext
39 | QString GenerateOutputPath(const QString &extension);
40 |
41 | // Check if output path was manually set by user
42 | bool IsOutputPathManuallySet() const;
43 |
44 | // Reset output path to auto-generate mode
45 | void ResetOutputPath();
46 |
47 | // Clear all data
48 | void Clear();
49 |
50 | private:
51 | QString inputFilePath;
52 | QString outputFilePath;
53 | bool outputPathManuallySet;
54 | };
55 |
56 | #endif // SHARED_DATA_H
57 |
--------------------------------------------------------------------------------
/src/component/src/progress_widget.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #include "progress_widget.h"
19 |
20 | ProgressWidget::ProgressWidget(QWidget *parent) : QWidget(parent) {
21 | // Create layout
22 | layout = new QVBoxLayout(this);
23 | layout->setContentsMargins(0, 0, 0, 0);
24 | layout->setSpacing(5);
25 |
26 | // Create progress bar
27 | progressBar = new QProgressBar(this);
28 | progressBar->setRange(0, 100);
29 | progressBar->setValue(0);
30 | progressBar->setVisible(false);
31 |
32 | // Create progress label
33 | progressLabel = new QLabel("", this);
34 | progressLabel->setVisible(false);
35 |
36 | // Add to layout
37 | layout->addWidget(progressBar);
38 | layout->addWidget(progressLabel);
39 |
40 | setLayout(layout);
41 | }
42 |
43 | void ProgressWidget::Show() {
44 | progressBar->setVisible(true);
45 | progressLabel->setVisible(true);
46 | }
47 |
48 | void ProgressWidget::Hide() {
49 | progressBar->setVisible(false);
50 | progressLabel->setVisible(false);
51 | }
52 |
53 | void ProgressWidget::Reset() {
54 | progressBar->setValue(0);
55 | progressLabel->setText("");
56 | }
57 |
--------------------------------------------------------------------------------
/src/builder/include/transcoder_helper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #ifndef TRANSCODER_HELPER_H
19 | #define TRANSCODER_HELPER_H
20 |
21 | #include
22 |
23 | class QWidget;
24 |
25 | /**
26 | * @brief Helper class to get current transcoder name from main window
27 | *
28 | * This class provides a centralized way to retrieve the currently selected
29 | * transcoder name from the OpenConverter main window. It eliminates code
30 | * duplication across pages and batch processing.
31 | *
32 | * Usage:
33 | * // From a page (QWidget)
34 | * QString transcoder = TranscoderHelper::GetCurrentTranscoderName(this);
35 | *
36 | * // From any QObject with parent widget
37 | * QString transcoder = TranscoderHelper::GetCurrentTranscoderName(parentWidget);
38 | */
39 | class TranscoderHelper {
40 | public:
41 | /**
42 | * @brief Get current transcoder name from main window
43 | * @param widget Any widget in the application (page, dialog, etc.)
44 | * @return Current transcoder name (e.g., "FFMPEG", "BMF", "FFTOOL")
45 | * Returns "FFMPEG" as default if main window not found
46 | */
47 | static QString GetCurrentTranscoderName(QWidget *widget);
48 | };
49 |
50 | #endif // TRANSCODER_HELPER_H
51 |
--------------------------------------------------------------------------------
/src/builder/include/base_page.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | #ifndef BASE_PAGE_H
19 | #define BASE_PAGE_H
20 |
21 | #include
22 |
23 | class QLineEdit;
24 | class SharedData;
25 |
26 | class BasePage : public QWidget {
27 | Q_OBJECT
28 |
29 | public:
30 | explicit BasePage(QWidget *parent = nullptr);
31 | virtual ~BasePage();
32 |
33 | // Virtual method to be called when page becomes active
34 | virtual void OnPageActivated();
35 |
36 | // Virtual method to be called when page becomes inactive
37 | virtual void OnPageDeactivated();
38 |
39 | // Get page title
40 | virtual QString GetPageTitle() const = 0;
41 |
42 | // Virtual method to retranslate UI when language changes
43 | virtual void RetranslateUi();
44 |
45 | protected:
46 | // Helper method to handle shared data updates
47 | // Derived classes should call this in OnPageActivated()
48 | void HandleSharedDataUpdate(QLineEdit *inputFileLineEdit,
49 | QLineEdit *outputFileLineEdit,
50 | const QString &defaultFormat = QString());
51 |
52 | // Hook method called when input file changes (override in derived classes if needed)
53 | virtual void OnInputFileChanged(const QString &newPath);
54 |
55 | // Hook method called when output path needs updating (override in derived classes if needed)
56 | virtual void OnOutputPathUpdate();
57 | };
58 |
59 | #endif // BASE_PAGE_H
60 |
--------------------------------------------------------------------------------
/doc/CompileGuide.md:
--------------------------------------------------------------------------------
1 | # OC Project Compilation Guide for Windows
2 |
3 | ## 1. Install Qt 5 or Qt 6
4 |
5 | ### 1.1 Download
6 |
7 | - [Official Website Download](https://download.qt.io/official_releases/online_installers/)
8 |
9 | Domestic mirrors:
10 |
11 | - [University of Science and Technology of China](http://mirrors.ustc.edu.cn/qtproject/)
12 | - [Tsinghua University](https://mirrors.tuna.tsinghua.edu.cn/qt/)
13 |
14 | ### 1.2 Installation
15 |
16 | #### 1.2.1 Qt Account Login
17 |
18 | Before starting the installation, you need to have a Qt account. If you don't have one, click the registration button on the page. (**This guide only covers the important steps for installing Qt.**)
19 |
20 | #### 1.2.2 Component Selection
21 |
22 | On the installation page, select the **Qt for Desktop Development** component and click **Next** to begin the installation.
23 |
24 | ## 2. Install and Configure FFmpeg
25 |
26 | Supported versions are 5.x to 7.x. The following example uses version 5.1.6.
27 |
28 | ### 2.1 Download FFmpeg 5.1.6
29 |
30 | [Download Link](https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2025-02-02-12-58/ffmpeg-n5.1.6-16-g6e63e49496-win64-lgpl-shared-5.1.zip)
31 |
32 | ### 2.2 Configure FFmpeg Environment
33 |
34 | Extract the downloaded ZIP file to a suitable location. Then, add the FFmpeg directory to your system’s environment variables.
35 |
36 | ## 3. Compile the OC Project
37 |
38 | ### 3.1 Project Configuration
39 |
40 | Open the OC project in Qt and configure it. Check the Qt compile suite and click **Configure Project**.
41 |
42 | ### 3.2 Configure FFmpeg Environment in CMake
43 |
44 | In the `CMakeLists.txt` file, find the **FFMPEG_ROOT_PATH** variable and set the FFmpeg environment path.
45 |
46 | ### 3.3 Disable BMF Compilation
47 |
48 | In the `CMakeLists.txt` file, locate the line:
49 |
50 | ```cmake
51 | option(BMF_TRANSCODER "Enable BMF Transcoder" ON)
52 | ```
53 |
54 | Change **ON** to **OFF**. If you wish to compile BMF, refer to the official [BMF installation guide for Windows](https://babitmf.github.io/docs/bmf/getting_started_yourself/install/#windows).
55 |
56 | ### 3.4 Compile the OC Project
57 |
58 | Once everything is set up, click the **Run** button in Qt to start the compilation process.
59 |
--------------------------------------------------------------------------------
/src/common/include/info.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Jack Lau
3 | * Email: jacklau1222gm@gmail.com
4 | *
5 | * This file is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This file is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | */
15 |
16 | #ifndef INFO_H
17 | #define INFO_H
18 |
19 | #include