Skip to content

Commit

Permalink
[Qt-Ffmpeg: 调整mpvplayer构建配置及依赖库引用]:对Qt-Ffmpeg项目的构建配置进行了调整,优化了mpvplaye…
Browse files Browse the repository at this point in the history
…r的构建流程,并更新了库的引用。

- 在`.github/workflows/qmake.yml`中,移除了`CONFIG-=BUILD_MPV`宏定义,现在默认包含mpvplayer的构建。
- 更新了`examples/examples.pro`,根据操作系统和存在条件,决定是否包含`mpvplayer`子目录。
- 修改了`examples/mpvplayer/CMakeLists.txt`,将`custommpv`库的引用更改为`qmpv`,并简化了条件判断,统一了不同操作系统下的链接库路径。
- 在`src/ffmpeg/codeccontext.cpp`中,对fdk aac编码器的质量参数格式化进行了修正。
- 对`src/mpv/CMakeLists.txt`和`src/mpv/mpv.pro`进行了一致性修改,将`custommpv`更改为`qmpv`,并更新了库的链接方式。
- 更新了`src/mpv/mpv.pri`和`src/mpv/mpv.pro`,统一了mpv库的链接路径,并移除了多余的配置项。
- 修改了`src/mpv/qthelper.hpp`,修复了类型比较的方式,使用`v.typeId()`替代`static_cast<int>(v.type())`。
- 在`src/src.pro`中,根据操作系统和存在条件,决定是否包含`mpv`子目录。
- 对`src/utils/CMakeLists.txt`和`src/utils/utils.pro`进行了小幅度修改,简化了库的构建配置。
  • Loading branch information
RealChuan committed Jun 6, 2024
1 parent 1891851 commit 54677fb
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/qmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
shell: pwsh
run: |
..\scripts\windows\setVsDev.ps1 -VersionRange "[16.0,17.0)" -Arch "x64"
& qmake "CONFIG-=BUILD_MPV" ./../.
& qmake ./../.
& jom
working-directory: build
- name: ubuntu-build
Expand All @@ -68,6 +68,6 @@ jobs:
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
qmake QMAKE_APPLE_DEVICE_ARCHS="arm64" ./../.
qmake ./../. QMAKE_APPLE_DEVICE_ARCHS="arm64"
make -j $(sysctl -n hw.ncpu)
working-directory: build
14 changes: 13 additions & 1 deletion examples/examples.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ SUBDIRS += \
ffmpegplayer \
ffmpegtranscoder

contains(CONFIG, BUILD_MPV) {
win32 {
exists("C:/3rd/x64/mpv/include"){
SUBDIRS += mpvplayer
}
}

macx {
exists("/opt/homebrew/include/mpv"){
SUBDIRS += mpvplayer
}
}

unix:!macx{
SUBDIRS += mpvplayer
}
7 changes: 3 additions & 4 deletions examples/mpvplayer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ qt_add_executable(MpvPlayer MANUAL_FINALIZATION ${PROJECT_SOURCES})
target_compile_definitions(MpvPlayer PRIVATE "MPV_ON")
target_link_libraries(
MpvPlayer
PRIVATE custommpv
PRIVATE qmpv
thirdparty
dump
utils
Expand All @@ -41,10 +41,9 @@ if(CMAKE_HOST_WIN32)
file(COPY C:\\3rd\\x64\\mpv\\libmpv-2.dll
DESTINATION ${EXECUTABLE_OUTPUT_PATH}/)
elseif(CMAKE_HOST_APPLE)
target_link_directories(MpvPlayer PRIVATE /usr/lib)
target_link_directories(MpvPlayer PRIVATE /usr/local/lib)
target_link_directories(MpvPlayer PRIVATE "/opt/homebrew/lib")
target_link_libraries(MpvPlayer PRIVATE mpv)
elseif(CMAKE_HOST_UNIX)
elseif(CMAKE_HOST_LINUX)
target_link_libraries(MpvPlayer PRIVATE mpv)
endif()

Expand Down
2 changes: 1 addition & 1 deletion examples/mpvplayer/mpvplayer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TARGET = MpvPlayer
DEFINES += MPV_ON

LIBS += \
-l$$replaceLibName(custommpv) \
-l$$replaceLibName(qmpv) \
-l$$replaceLibName(thirdparty) \
-l$$replaceLibName(dump) \
-l$$replaceLibName(utils)
Expand Down
2 changes: 1 addition & 1 deletion src/ffmpeg/codeccontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class CodecContext::CodecContextPrivate
codecCtx->global_quality = encodeContext.crf * FF_QP2LAMBDA;
codecCtx->flags |= AV_CODEC_FLAG_QSCALE;
if (encodeContext.codecInfo().name.contains("fdk")) {
auto vbr = QString::asprintf("%.1g", encodeContext.crf);
auto vbr = QString::asprintf("%.1d", encodeContext.crf);
av_dict_set(&encodeOptions, "vbr", vbr.toUtf8().data(), 0);
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/mpv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ set(PROJECT_SOURCES
previewwidget.hpp
qthelper.hpp)

add_custom_library(custommpv ${PROJECT_SOURCES} ${SOURCES})
target_link_libraries(custommpv PRIVATE Qt6::Widgets Qt6::OpenGLWidgets)
add_custom_library(qmpv ${PROJECT_SOURCES})
target_link_libraries(qmpv PRIVATE Qt6::Widgets Qt6::OpenGLWidgets)

if(CMAKE_HOST_WIN32)
target_include_directories(custommpv PRIVATE "C:\\3rd\\x64\\mpv\\include")
target_link_libraries(custommpv PRIVATE C:\\3rd\\x64\\mpv\\libmpv.dll.a)
target_include_directories(qmpv PRIVATE "C:\\3rd\\x64\\mpv\\include")
target_link_libraries(qmpv PRIVATE C:\\3rd\\x64\\mpv\\libmpv.dll.a)
elseif(CMAKE_HOST_APPLE)
target_include_directories(custommpv PRIVATE "/usr/local/include")
target_link_directories(custommpv PRIVATE /usr/lib)
target_link_directories(custommpv PRIVATE /usr/local/lib)
target_link_libraries(custommpv PRIVATE mpv)
target_include_directories(qmpv PRIVATE "/opt/homebrew/include")
target_link_directories(qmpv PRIVATE "/opt/homebrew/lib")
target_link_libraries(qmpv PRIVATE mpv)
elseif(CMAKE_HOST_LINUX)
target_link_libraries(custommpv PRIVATE mpv)
target_link_libraries(qmpv PRIVATE mpv)
endif()

if(CMAKE_HOST_WIN32)
target_compile_definitions(custommpv PRIVATE "MPV_LIBRARY")
target_compile_definitions(qmpv PRIVATE "MPV_LIBRARY")
endif()
8 changes: 4 additions & 4 deletions src/mpv/mpv.pri
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig debug
# CONFIG += link_pkgconfig debug
#PKGCONFIG += mpv

win32 {
Expand All @@ -8,11 +8,11 @@ win32 {
}

macx {
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/lib -L/usr/local/lib
INCLUDEPATH += /opt/homebrew/include
LIBS += -L/opt/homebrew/lib
LIBS += -lmpv
}

unix:!macx{
LIBS += -lmpv
}
}
2 changes: 1 addition & 1 deletion src/mpv/mpv.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(mpv.pri)
QT += core gui network widgets openglwidgets

DEFINES += MPV_LIBRARY
TARGET = $$replaceLibName(custommpv)
TARGET = $$replaceLibName(qmpv)

SOURCES += \
mediainfo.cc \
Expand Down
2 changes: 1 addition & 1 deletion src/mpv/qthelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct node_builder
// "QVariant::Type(obsolete), the return value should be interpreted
// as QMetaType::Type."
// So a cast really seems to be needed to avoid warnings (urgh).
return static_cast<int>(v.type()) == static_cast<int>(t);
return v.typeId() == static_cast<int>(t);
}
void set(mpv_node *dst, const QVariant &src)
{
Expand Down
14 changes: 13 additions & 1 deletion src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ SUBDIRS += \
3rdparty \
ffmpeg

contains(CONFIG, BUILD_MPV) {
win32 {
exists("C:/3rd/x64/mpv/include"){
SUBDIRS += mpv
}
}

macx {
exists("/opt/homebrew/include/mpv"){
SUBDIRS += mpv
}
}

unix:!macx{
SUBDIRS += mpv
}
2 changes: 1 addition & 1 deletion src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(PROJECT_SOURCES
utils.h
utilstr.h)

add_custom_library(utils ${PROJECT_SOURCES} ${SOURCES})
add_custom_library(utils ${PROJECT_SOURCES})
target_link_libraries(utils PRIVATE Qt6::Widgets Qt6::Core5Compat)

if(CMAKE_HOST_WIN32)
Expand Down
6 changes: 1 addition & 5 deletions src/utils/utils.pro
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
include(../slib.pri)

QT += widgets

greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat
QT += widgets core5compat

DEFINES += UTILS_LIBRARY
TARGET = $$replaceLibName(utils)

DEFINES += QT_DEPRECATED_WARNINGS

SOURCES += \
countdownlatch.cc \
fps.cc \
Expand Down

0 comments on commit 54677fb

Please sign in to comment.