From 35d00925fcc83eb77b42faf03419be437ce17168 Mon Sep 17 00:00:00 2001 From: sladro Date: Fri, 27 Feb 2026 18:57:45 +0800 Subject: [PATCH] Enhance MPP library detection logic with explicit overrides and fallback mechanisms --- docs/命令.md | 2 +- plugins/CMakeLists.txt | 55 +++++++++++++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/docs/命令.md b/docs/命令.md index f198428..5b5a011 100644 --- a/docs/命令.md +++ b/docs/命令.md @@ -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 diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 70ff20c..37b7a27 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -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()