From 89bd3a0e84f207a947f7617a3e2544066eda928c Mon Sep 17 00:00:00 2001 From: rewine Date: Tue, 22 Aug 2023 14:42:26 +0800 Subject: [PATCH] feat: just use QLibrary to search .so MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Log: When loading the library, QLibrary searches in all the system-specific library locations (e.g. LD_LIBRARY_PATH on Unix), unless the file name has an absolute path. for linux, will use dlopen in QLibrary: https://man7.org/linux/man-pages/man3/dlopen.3.html --- .../service/ffmpegvideothumbnailer.cpp | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/libimageviewer/service/ffmpegvideothumbnailer.cpp b/libimageviewer/service/ffmpegvideothumbnailer.cpp index a3c875ae..a789f271 100644 --- a/libimageviewer/service/ffmpegvideothumbnailer.cpp +++ b/libimageviewer/service/ffmpegvideothumbnailer.cpp @@ -30,28 +30,9 @@ static video_thumbnailer *m_video_thumbnailer = nullptr; //解析成功标记 static bool resolveSuccessed = false; -static QString libPath(const QString &strlib) -{ - QDir dir; - QString path = QLibraryInfo::location(QLibraryInfo::LibrariesPath); - dir.setPath(path); - QStringList list = dir.entryList(QStringList() << (strlib + "*"), QDir::NoDotAndDotDot | QDir::Files); //filter name with strlib - if (list.contains(strlib)) { - return strlib; - } else { - list.sort(); - } - - if (list.size() > 0) { - return list.last(); - } else { - return QString(); - } -} - bool initFFmpegVideoThumbnailer() { - QLibrary library(libPath("libffmpegthumbnailer.so")); + QLibrary library("libffmpegthumbnailer.so"); m_creat_video_thumbnailer = reinterpret_cast(library.resolve("video_thumbnailer_create")); m_mvideo_thumbnailer_destroy = reinterpret_cast(library.resolve("video_thumbnailer_destroy")); m_mvideo_thumbnailer_create_image_data = reinterpret_cast(library.resolve("video_thumbnailer_create_image_data"));