Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
include:
- arch: x86_64
runner: ubuntu-22.04
ffmpeg_url: https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-11-30-13-12/ffmpeg-n5.1.6-11-gcde3c5fc0c-linux64-gpl-shared-5.1.tar.xz
ffmpeg_dir: ffmpeg-n5.1.6-11-gcde3c5fc0c-linux64-gpl-shared-5.1
ffmpeg_url: https://github.com/FFmpeg-Builds/FFmpeg-Builds/releases/download/autobuild-2025-01-31-12-58/ffmpeg-n5.1.6-16-g6e63e49496-linux64-gpl-shared-5.1.tar.xz
ffmpeg_dir: ffmpeg-n5.1.6-16-g6e63e49496-linux64-gpl-shared-5.1
bmf_url: https://github.com/OpenConverterLab/bmf/releases/download/oc0.0.3/bmf-bin-linux-x86_64-cp39.tar.gz
appimagetool: appimagetool-x86_64.AppImage
- arch: aarch64
runner: ubuntu-22.04-arm
ffmpeg_url: https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-11-30-13-12/ffmpeg-n5.1.6-11-gcde3c5fc0c-linuxarm64-gpl-shared-5.1.tar.xz
ffmpeg_dir: ffmpeg-n5.1.6-11-gcde3c5fc0c-linuxarm64-gpl-shared-5.1
ffmpeg_url: https://github.com/FFmpeg-Builds/FFmpeg-Builds/releases/download/autobuild-2025-01-31-12-58/ffmpeg-n5.1.6-16-g6e63e49496-linuxarm64-gpl-shared-5.1.tar.xz
ffmpeg_dir: ffmpeg-n5.1.6-16-g6e63e49496-linuxarm64-gpl-shared-5.1
bmf_url: https://github.com/OpenConverterLab/bmf/releases/download/oc0.0.3/bmf-bin-linux-aarch64-cp39.tar.gz
appimagetool: appimagetool-aarch64.AppImage
runs-on: ${{ matrix.runner }}
Expand Down Expand Up @@ -81,7 +81,7 @@
export PATH=$(readlink -f /tmp/.mount_QtCreator-*-${{ matrix.arch }}/*/gcc_64/bin/):$PATH
(cd linuxdeployqt && qmake && make && sudo make install)
# patchelf
wget https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fL -O https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2
tar xf patchelf-0.9.tar.bz2
( cd patchelf-0.9/ && ./configure && make && sudo make install )
# appimage
Expand Down Expand Up @@ -114,7 +114,7 @@
cp -r $BMF_ROOT_PATH src/build/
(mkdir -p src/build/modules/weights &&
cd src/build/modules/weights &&
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth)
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fL -O https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth)

# Step to package the build directory
- name: Create tar.gz package
Expand Down Expand Up @@ -242,7 +242,7 @@

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 # v3

- name: Upload Linglong package
uses: actions/upload-artifact@v4
Expand All @@ -254,148 +254,148 @@
run: echo "Linglong build complete"

build-macos-arm:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: "review-macos-${{ github.event.pull_request.number }}"
cancel-in-progress: true

steps:
- name: Checkout target branch code (using pull_request)
uses: actions/checkout@v2

- name: Print current branch and commit hash
run: |
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
echo "Current commit hash: $(git rev-parse HEAD)"

- name: Install FFmpeg and Qt via Homebrew
run: |
# Install FFmpeg 5 with x264, x265 support (pre-built from Homebrew)
brew install ffmpeg@5 qt@5 python@3.9

# Set FFmpeg path
export FFMPEG_ROOT_PATH=$(brew --prefix ffmpeg@5)
echo "FFMPEG_ROOT_PATH=$FFMPEG_ROOT_PATH" >> $GITHUB_ENV

# Verify FFmpeg has x264 and x265
echo "FFmpeg configuration:"
$FFMPEG_ROOT_PATH/bin/ffmpeg -version | head -n 1
$FFMPEG_ROOT_PATH/bin/ffmpeg -encoders 2>/dev/null | grep -E "libx264|libx265" || echo "Warning: x264/x265 not found"

- name: Checkout BMF repository and prepare python support
run: |
git clone https://github.com/OpenConverterLab/bmf.git
sed -i '' '77 i\
-DPython_ROOT_DIR="$HOME/Library/Application Support/OpenConverter/Python.framework" \\\
-DPython_FIND_FRAMEWORK=ONLY \\\
' ./bmf/build_osx.sh

mkdir -p "$HOME/Library/Application Support/OpenConverter/Python.framework"
wget https://github.com/astral-sh/python-build-standalone/releases/download/20251031/cpython-3.9.25+20251031-aarch64-apple-darwin-install_only.tar.gz
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fL -O https://github.com/astral-sh/python-build-standalone/releases/download/20251031/cpython-3.9.25+20251031-aarch64-apple-darwin-install_only.tar.gz
tar xzvf cpython-3.9.25+20251031-aarch64-apple-darwin-install_only.tar.gz --strip-components=1 -C "$HOME/Library/Application Support/OpenConverter/Python.framework"

# wget https://invisible-island.net/archives/ncurses/ncurses-6.5.tar.gz
# wget https://ftp.gnu.org/gnu/binutils/binutils-2.43.1.tar.bz2

# - name: Cache ncurses build
# uses: actions/cache@v3
# with:
# path: opt/ncurses
# key: ${{ runner.os }}-ncurses-${{ hashFiles('ncurses-6.5.tar.gz') }}
# restore-keys: |
# ${{ runner.os }}-ncurses-

# - name: Cache binutils build
# uses: actions/cache@v3
# with:
# path: opt/binutils
# key: ${{ runner.os }}-binutils-${{ hashFiles('binutils-2.43.1.tar.bz2') }}
# restore-keys: |
# ${{ runner.os }}-binutils-

# - name: compile dependencies
# run: |
# if [ ! -d "$(pwd)/opt/ncurses" ]; then
# tar -xzvf ncurses-6.5.tar.gz
# (cd ncurses-6.5 && ./configure --prefix=/Users/runner/work/OpenConverter/OpenConverter/opt/ncurses && make -j$(sysctl -n hw.ncpu) && sudo make install)
# else
# echo "ncurses is already installed, skipping build."
# fi

# if [ ! -d "$(pwd)/opt/binutils" ]; then
# tar xvf binutils-2.43.1.tar.bz2
# (cd binutils-2.43.1 && ./configure --prefix=/Users/runner/work/OpenConverter/OpenConverter/opt/binutils --enable-install-libiberty && make -j$(sysctl -n hw.ncpu) && sudo make install)
# else
# echo "binutils is already installed, skipping build."
# fi

# - name: Cache BMF build
# uses: actions/cache@v3
# with:
# path: bmf/output/
# key: ${{ runner.os }}-bmf-${{ hashFiles('bmf/build.sh') }}
# restore-keys: |
# ${{ runner.os }}-bmf-macos-arm-

- name: Set up BMF if not cached
run: |
if [ ! -d "$(pwd)/bmf/output/" ]; then
# export LIBRARY_PATH=$(pwd)/opt/binutils/lib:$LIBRARY_PATH
# export CMAKE_PREFIX_PATH=$(pwd)/opt/binutils:$CMAKE_PREFIX_PATH
brew link --force python@3.9
export BMF_PYTHON_VERSION="3.9"
pip install setuptools
pip install --only-binary :all: 'setuptools==69.5.1'
(cd bmf && git checkout oc && git submodule update --init --recursive && ./build_osx.sh)
else
echo "BMF is already installed, skipping build."
fi
echo "BMF_ROOT_PATH=$(pwd)/bmf/output/bmf" >> $GITHUB_ENV

- name: Build and Deploy
run: |
export PATH="$(brew --prefix ffmpeg@5)/bin:$PATH"
export CMAKE_PREFIX_PATH="$(brew --prefix qt@5):$CMAKE_PREFIX_PATH"
export QT_DIR="$(brew --prefix qt@5)/lib/cmake/Qt5"
export PATH="$(brew --prefix qt@5)/bin:$PATH"

cd src
cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DFFMPEG_ROOT_PATH="$(brew --prefix ffmpeg@5)" \
-DBMF_TRANSCODER=ON

cd build
make -j$(sysctl -n hw.ncpu)

# Use the fix_macos_libs.sh script to handle deployment
cd ..
chmod +x ../tool/fix_macos_libs.sh
../tool/fix_macos_libs.sh

cd build

# Create DMG using simple shell script
echo "Creating DMG..."
chmod +x ../../tool/create_dmg_simple.sh
../../tool/create_dmg_simple.sh OpenConverter.app

cd ../..
mv src/build/OpenConverter.dmg OpenConverter_macOS_aarch64.dmg

# Step to upload the dmg package as an artifact
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: OpenConverter_macOS_aarch64
path: OpenConverter_macOS_aarch64.dmg

# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3

- name: Finish
run: echo "Release upload complete"

build-windows-x64:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: windows-latest
concurrency:
group: "review-win-${{ github.event.pull_request.number }}"
Expand All @@ -408,7 +408,7 @@

# Set up the Qt environment.
- name: (2) Install Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@b7840a6733f49e2a39c4355260d2375063d39b61 # v3
with:
version: 6.8.3
host: windows
Expand All @@ -421,17 +421,17 @@
- name: Download FFmpeg
shell: powershell
run: |
$ffmpegUrl = "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-11-30-13-12/ffmpeg-n5.1.6-11-gcde3c5fc0c-win64-gpl-shared-5.1.zip"
$ffmpegUrl = "https://github.com/FFmpeg-Builds/FFmpeg-Builds/releases/download/autobuild-2025-01-31-12-58/ffmpeg-n5.1.6-16-g6e63e49496-win64-gpl-shared-5.1.zip"
$outputZip = "ffmpeg.zip"
Invoke-WebRequest -Uri $ffmpegUrl -OutFile $outputZip
Expand-Archive -Path $outputZip -DestinationPath ffmpeg
echo "FFMPEG_ROOT_PATH=$(pwd)/ffmpeg/ffmpeg-n5.1.6-11-gcde3c5fc0c-win64-gpl-shared-5.1" >> $GITHUB_ENV
echo "FFMPEG_ROOT_PATH=$(pwd)/ffmpeg/ffmpeg-n5.1.6-16-g6e63e49496-win64-gpl-shared-5.1" >> $GITHUB_ENV

# Create a build directory, run qmake, and build the project.
- name: Build Qt project
run: |
(cd src &&
cmake -S . -B build "-DFFMPEG_ROOT_PATH=../ffmpeg/ffmpeg-n5.1.6-11-gcde3c5fc0c-win64-gpl-shared-5.1" -DFFTOOL_TRANSCODER=OFF -DBMF_TRANSCODER=OFF &&
cmake -S . -B build "-DFFMPEG_ROOT_PATH=../ffmpeg/ffmpeg-n5.1.6-16-g6e63e49496-win64-gpl-shared-5.1" -DFFTOOL_TRANSCODER=OFF -DBMF_TRANSCODER=OFF &&
cmake --build build --config Release --parallel)

- name : Deploy project
Expand All @@ -457,7 +457,7 @@

# 4) Copy FFmpeg DLLs into OpenConverter_win64/
Copy-Item `
-Path "ffmpeg\ffmpeg-n5.1.6-11-gcde3c5fc0c-win64-gpl-shared-5.1\bin\*.dll" `
-Path "ffmpeg\ffmpeg-n5.1.6-16-g6e63e49496-win64-gpl-shared-5.1\bin\*.dll" `
-Destination "OpenConverter_win64"

# 5) Bundle the MSVC C++ runtime app-local. The app directory wins over
Expand Down Expand Up @@ -566,7 +566,7 @@

cd ..
echo "Release packages:"
ls -la *.tar.gz *.dmg *.zip *.layer 2>/dev/null || echo "Some packages may be missing"

Check warning on line 569 in .github/workflows/build.yaml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefix files and paths with "./" or "--" when using glob.

See more on https://sonarcloud.io/project/issues?id=OpenConverterLab_OpenConverter&issues=AaIC2fDX08cVoQfRAqvp&open=AaIC2fDX08cVoQfRAqvp&pullRequest=159

# Build dynamic file list for upload (only files that actually exist)
FILES=""
Expand Down Expand Up @@ -596,7 +596,7 @@

- name: Upload Release Assets
if: steps.prepare.outputs.HAS_FILES == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
with:
files: ${{ steps.prepare.outputs.FILES }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:

- name: Get FFmpeg
run: |
wget https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-11-30-13-12/ffmpeg-n5.1.6-11-gcde3c5fc0c-linux64-gpl-shared-5.1.tar.xz
tar xJvf ffmpeg-n5.1.6-11-gcde3c5fc0c-linux64-gpl-shared-5.1.tar.xz
ls ffmpeg-n5.1.6-11-gcde3c5fc0c-linux64-gpl-shared-5.1
echo "FFMPEG_ROOT_PATH=$(pwd)/ffmpeg-n5.1.6-11-gcde3c5fc0c-linux64-gpl-shared-5.1" >> $GITHUB_ENV
wget https://github.com/FFmpeg-Builds/FFmpeg-Builds/releases/download/autobuild-2025-01-31-12-58/ffmpeg-n5.1.6-16-g6e63e49496-linux64-gpl-shared-5.1.tar.xz
tar xJvf ffmpeg-n5.1.6-16-g6e63e49496-linux64-gpl-shared-5.1.tar.xz
ls ffmpeg-n5.1.6-16-g6e63e49496-linux64-gpl-shared-5.1
echo "FFMPEG_ROOT_PATH=$(pwd)/ffmpeg-n5.1.6-16-g6e63e49496-linux64-gpl-shared-5.1" >> $GITHUB_ENV

- name: Build with CMake
run: |
Expand Down
19 changes: 17 additions & 2 deletions src/builder/src/batch_queue_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "../include/batch_queue_dialog.h"
#include "../../engine/include/converter.h"
#include "../../common/include/logger.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QHeaderView>
Expand All @@ -25,6 +26,8 @@
#include <QDebug>
#include <QThread>
#include <QMetaObject>
#include <exception>
#include <string>

BatchQueueDialog::BatchQueueDialog(QWidget *parent)
: QDialog(parent),
Expand Down Expand Up @@ -376,15 +379,27 @@
QString outputPath = item->GetOutputPath();
QString transcoderName = item->GetTranscoderName();

QThread *thread = QThread::create([this, inputPath, outputPath, encodeParam, processParam, transcoderName]() {

Check warning on line 382 in src/builder/src/batch_queue_dialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This lambda has 27 lines, which is greater than the 20 lines authorized. Split it into several lambdas or functions, or make it a named function.

See more on https://sonarcloud.io/project/issues?id=OpenConverterLab_OpenConverter&issues=AaIC1o43wEz4wE4bC52Z&open=AaIC1o43wEz4wE4bC52Z&pullRequest=159
bool success = false;

try {
Converter converter(processParam, encodeParam);
converter.set_transcoder(transcoderName.toStdString());
success = converter.convert_format(inputPath.toStdString(), outputPath.toStdString());
if (!converter.set_transcoder(transcoderName.toStdString())) {
success = false;
} else {
success = converter.convert_format(inputPath.toStdString(),
outputPath.toStdString());
}
} catch (const std::exception &ex) {

Check warning on line 393 in src/builder/src/batch_queue_dialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Catch a more specific exception instead of a generic one.

See more on https://sonarcloud.io/project/issues?id=OpenConverterLab_OpenConverter&issues=AaIC1o43wEz4wE4bC52a&open=AaIC1o43wEz4wE4bC52a&pullRequest=159
success = false;
const char *what = ex.what();
Logger::Log(std::string("Batch conversion aborted by exception: ") +
(what ? what : "std::exception"),
true);
} catch (...) {
success = false;
Logger::Log("Batch conversion aborted by an unknown exception.",
true);
}

// Remove observer and clean up
Expand Down
36 changes: 27 additions & 9 deletions src/builder/src/converter_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
*/

#include "../include/converter_runner.h"
#include "../../common/include/logger.h"
#include "../../common/include/encode_parameter.h"
#include "../../common/include/process_parameter.h"
#include "../../engine/include/converter.h"
#include <QMessageBox>
#include <QMetaObject>
#include <QThread>
#include <exception>
#include <memory>
#include <string>

ConverterRunner::ConverterRunner(QProgressBar *progressBar,
QLabel *progressLabel,
Expand Down Expand Up @@ -80,16 +84,30 @@
SetButtonRunning();

// Run conversion in a separate thread
QThread *thread = QThread::create([this, inputPath, outputPath, encodeParam, processParam, transcoderName]() {

Check warning on line 87 in src/builder/src/converter_runner.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This lambda has 33 lines, which is greater than the 20 lines authorized. Split it into several lambdas or functions, or make it a named function.

See more on https://sonarcloud.io/project/issues?id=OpenConverterLab_OpenConverter&issues=AaIC1o7lwEz4wE4bC52c&open=AaIC1o7lwEz4wE4bC52c&pullRequest=159
// Create converter
Converter *converter = new Converter(processParam, encodeParam);
converter->set_transcoder(transcoderName.toStdString());

// Perform conversion
bool success = converter->convert_format(inputPath.toStdString(), outputPath.toStdString());

// Clean up converter
delete converter;
bool success = false;

try {
// unique_ptr so a throw cannot leak the converter. An exception
// leaving this thread would terminate the process.
auto converter =
std::make_unique<Converter>(processParam, encodeParam);
if (!converter->set_transcoder(transcoderName.toStdString())) {
success = false;
} else {
success = converter->convert_format(inputPath.toStdString(),
outputPath.toStdString());
}
} catch (const std::exception &ex) {

Check warning on line 101 in src/builder/src/converter_runner.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Catch a more specific exception instead of a generic one.

See more on https://sonarcloud.io/project/issues?id=OpenConverterLab_OpenConverter&issues=AaIC1o7lwEz4wE4bC52d&open=AaIC1o7lwEz4wE4bC52d&pullRequest=159
success = false;
const char *what = ex.what();
Logger::Log(std::string("Conversion aborted by exception: ") +
(what ? what : "std::exception"),
true);
} catch (...) {

Check warning on line 107 in src/builder/src/converter_runner.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"catch" a specific exception type.

See more on https://sonarcloud.io/project/issues?id=OpenConverterLab_OpenConverter&issues=AaIC1o7lwEz4wE4bC52e&open=AaIC1o7lwEz4wE4bC52e&pullRequest=159
success = false;
Logger::Log("Conversion aborted by an unknown exception.", true);
}

// Emit signal to notify completion (will be handled on main thread)
QMetaObject::invokeMethod(this, [this, success]() {
Expand Down
8 changes: 5 additions & 3 deletions src/builder/src/extract_audio_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QGridLayout>
#include <QHBoxLayout>
#include <QMessageBox>
#include <string>

ExtractAudioPage::ExtractAudioPage(QWidget *parent) : BasePage(parent), converterRunner(nullptr) {
SetupUI();
Expand Down Expand Up @@ -258,10 +259,11 @@ void ExtractAudioPage::UpdateOutputPath() {

QString ExtractAudioPage::DetectAudioCodecFromFile(const QString &filePath) {
Info info;
QByteArray ba = filePath.toLocal8Bit();
char *src = ba.data();
// Stable UTF-8 path, mirroring the video player's FFmpeg usage; avoids
// feeding avformat a pointer into a short-lived toLocal8Bit() buffer.
std::string path = filePath.toStdString();

info.send_info(src);
info.send_info(path);
QuickInfo *quickInfo = info.get_quick_info();

if (quickInfo && quickInfo->audioIdx >= 0) {
Expand Down
10 changes: 7 additions & 3 deletions src/builder/src/info_view_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QFileDialog>
#include <QHBoxLayout>
#include <QMessageBox>
#include <string>

InfoViewPage::InfoViewPage(QWidget *parent) : BasePage(parent) {
info = new Info();
Expand Down Expand Up @@ -196,11 +197,14 @@ void InfoViewPage::AnalyzeFile(const QString &filePath) {
return;
}

QByteArray ba = filePath.toLocal8Bit();
char *src = ba.data();
// Pass the path as a stable UTF-8 std::string (mirrors how the video
// player feeds FFmpeg). Avoid avformat consuming a pointer into a
// short-lived QByteArray whose local-code-page encoding and buffer
// lifetime are not guaranteed on all Windows systems.
std::string path = filePath.toStdString(); // QString -> UTF-8 std::string

// Get info by analyzing the file
info->send_info(src);
info->send_info(path);

// Display info
DisplayInfo(info->get_quick_info());
Expand Down
Loading
Loading