diff --git a/libimageviewer/movieservice.cpp b/libimageviewer/movieservice.cpp index c5d61dce..50f6186f 100644 --- a/libimageviewer/movieservice.cpp +++ b/libimageviewer/movieservice.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "unionimage/baseutils.h" #include "service/ffmpegvideothumbnailer.h" @@ -211,12 +212,16 @@ QImage MovieService::getMovieCover_ffmpegthumbnailer(const QUrl &url, const QStr } QString path = url.toLocalFile(); + QString savePath; QFileInfo info(path); + QTemporaryDir tempDir; + // 此处临时文件创建后被删除,调整为使用tmp目录 + if (tempDir.isValid()) { + savePath = tempDir.filePath(info.fileName() + ".png"); + } else { + savePath = QString(bufferPath + info.fileName() + ".png"); + } - //QString savePath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QDir::separator() + info.fileName() + ".png"); - QString savePath(bufferPath + info.fileName() + ".png"); - - QByteArray output; try { QProcess ffmpegthumbnailer; QStringList cmds{"-i", path, "-o", savePath}; diff --git a/libimageviewer/service/ffmpegvideothumbnailer.cpp b/libimageviewer/service/ffmpegvideothumbnailer.cpp index a789f271..1ddc0ebe 100644 --- a/libimageviewer/service/ffmpegvideothumbnailer.cpp +++ b/libimageviewer/service/ffmpegvideothumbnailer.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -32,12 +33,19 @@ static bool resolveSuccessed = false; bool initFFmpegVideoThumbnailer() { - QLibrary library("libffmpegthumbnailer.so"); + QLibrary library("libffmpegthumbnailer.so.4"); + 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")); m_mvideo_thumbnailer_destroy_image_data = reinterpret_cast(library.resolve("video_thumbnailer_destroy_image_data")); m_mvideo_thumbnailer_generate_thumbnail_to_buffer = reinterpret_cast(library.resolve("video_thumbnailer_generate_thumbnail_to_buffer")); + + if (nullptr == m_creat_video_thumbnailer) { + qWarning() << QString("Resolve libffmpegthumbnailer.so data failed, %1").arg(library.errorString()); + resolveSuccessed = false; + return false; + } m_video_thumbnailer = m_creat_video_thumbnailer(); if (m_mvideo_thumbnailer_destroy == nullptr