Enhance MPP library detection logic with explicit overrides and fallback mechanisms

This commit is contained in:
sladro 2026-02-27 18:57:45 +08:00
parent d1f0aa4255
commit 35d00925fc
2 changed files with 47 additions and 10 deletions

View File

@ -1,7 +1,7 @@
# 开发和部署所需的命令
ffmpeg -f dshow -i video="1080P USB Camera" -c:v libx264 -preset ultrafast -pix_fmt yuv420p -f rtsp rtsp://localhost:8554/cam
ffmpeg -f dshow -video_size 1280x720 -vcodec mjpeg -i video="1080P USB Camera" -c:v libx264 -preset ultrafast -pix_fmt yuv420p -f rtsp rtsp://localhost:8554/cam

View File

@ -23,16 +23,53 @@ if(RK3588_ENABLE_FFMPEG)
endif()
if(RK3588_ENABLE_MPP)
# Prefer user-provided lib path; otherwise search common locations including rknpu2 prebuilts.
find_library(RK_MPP_LIB rockchip_mpp
HINTS
${RK_MPP_LIB_PATH}
${RK_MPP_ROOT}/build
${RK_MPP_ROOT}/lib
${RK_RKNN_ROOT}/examples/3rdparty/mpp/Linux/aarch64
${RK_RKNN_ROOT}/examples/3rdparty/mpp/Linux/armhf
NO_DEFAULT_PATH
set(_RK_MPP_HINT_DIRS
${RK_MPP_ROOT}/build
${RK_MPP_ROOT}/lib
${RK_RKNN_ROOT}/examples/3rdparty/mpp/Linux/aarch64
${RK_RKNN_ROOT}/examples/3rdparty/mpp/Linux/armhf
)
# 1) Explicit override always wins.
if(RK_MPP_LIB_PATH AND EXISTS "${RK_MPP_LIB_PATH}")
set(RK_MPP_LIB "${RK_MPP_LIB_PATH}")
endif()
# 2) Prefer versioned ELF soname file to avoid broken/non-symlink placeholders.
if(NOT RK_MPP_LIB)
foreach(_dir IN LISTS _RK_MPP_HINT_DIRS)
if(EXISTS "${_dir}/librockchip_mpp.so.0")
set(RK_MPP_LIB "${_dir}/librockchip_mpp.so.0")
break()
endif()
endforeach()
endif()
# 3) Fallback to generic search.
if(NOT RK_MPP_LIB)
find_library(RK_MPP_LIB rockchip_mpp
HINTS
${_RK_MPP_HINT_DIRS}
NO_DEFAULT_PATH
)
endif()
# If a tiny placeholder file (common after zip/copy on Windows) is selected,
# auto-fallback to sibling librockchip_mpp.so.0 when available.
if(RK_MPP_LIB AND EXISTS "${RK_MPP_LIB}")
file(SIZE "${RK_MPP_LIB}" _RK_MPP_SIZE)
if(_RK_MPP_SIZE LESS 1024)
get_filename_component(_RK_MPP_DIR "${RK_MPP_LIB}" DIRECTORY)
if(EXISTS "${_RK_MPP_DIR}/librockchip_mpp.so.0")
file(SIZE "${_RK_MPP_DIR}/librockchip_mpp.so.0" _RK_MPP_SO0_SIZE)
if(_RK_MPP_SO0_SIZE GREATER 1024)
set(RK_MPP_LIB "${_RK_MPP_DIR}/librockchip_mpp.so.0")
message(STATUS "Detected placeholder librockchip_mpp.so, switched to ${RK_MPP_LIB}")
endif()
endif()
endif()
endif()
if(NOT RK_MPP_LIB)
find_library(RK_MPP_LIB rockchip_mpp)
endif()