diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,12 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set(QT_MIN_VERSION "5.2.0") +include(FindPkgConfig) + +if(NOT PKG_CONFIG_FOUND) + message(FATAL_ERROR "pkg-config not found!" ) +endif() + find_package(ECM 1.0.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -12,6 +18,7 @@ include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) +pkg_check_modules(taglib REQUIRED IMPORTED_TARGET taglib) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui) find_package(KF5 REQUIRED COMPONENTS KIO I18n Config) find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT SWSCALE) @@ -39,7 +46,7 @@ kconfig_add_kcfg_files(ffmpegthumbs_PART_SRCS ffmpegthumbnailersettings5.kcfgc) add_library(ffmpegthumbs MODULE ${ffmpegthumbs_PART_SRCS}) -target_link_libraries(ffmpegthumbs Qt5::Core Qt5::Gui KF5::KIOWidgets KF5::KIOCore KF5::I18n KF5::ConfigCore KF5::ConfigGui ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} ) +target_link_libraries(ffmpegthumbs Qt5::Core Qt5::Gui KF5::KIOWidgets KF5::KIOCore KF5::I18n KF5::ConfigCore KF5::ConfigGui ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} PkgConfig::taglib ) install(FILES ffmpegthumbnailersettings5.kcfg DESTINATION ${KCFG_INSTALL_DIR}) install(TARGETS ffmpegthumbs DESTINATION ${PLUGIN_INSTALL_DIR}) diff --git a/ffmpegthumbnailer.cpp b/ffmpegthumbnailer.cpp --- a/ffmpegthumbnailer.cpp +++ b/ffmpegthumbnailer.cpp @@ -1,4 +1,5 @@ // Copyright (C) 2010 Dirk Vanden Boer +// Copyright (C) 2019 Heiko Schäfer // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -17,6 +18,8 @@ #include "ffmpegthumbnailer.h" #include "ffmpegthumbnailersettings5.h" +#include + #include #include #include @@ -44,6 +47,24 @@ bool FFMpegThumbnailer::create(const QString& path, int width, int /*height*/, QImage& img) { + TagLib::MP4::File f(path.toStdString().c_str(), false); + + if (f.isValid()) { + + TagLib::MP4::Tag* tag = f.tag(); + TagLib::MP4::ItemListMap itemsListMap = tag->itemListMap(); + TagLib::MP4::Item coverItem = itemsListMap["covr"]; + TagLib::MP4::CoverArtList coverArtList = coverItem.toCoverArtList(); + + if (!coverArtList.isEmpty()) { + TagLib::MP4::CoverArt coverArt = coverArtList.front(); + img.loadFromData((const uchar *)coverArt.data().data(), + coverArt.data().size()); + + if (!img.isNull()) return true; + } + } + m_Thumbnailer.setThumbnailSize(width); // 20% seek inside the video to generate the preview m_Thumbnailer.setSeekPercentage(20); diff --git a/ffmpegthumbnailer/filmstripfilter.h b/ffmpegthumbnailer/filmstripfilter.h --- a/ffmpegthumbnailer/filmstripfilter.h +++ b/ffmpegthumbnailer/filmstripfilter.h @@ -26,7 +26,7 @@ { public: virtual ~FilmStripFilter() {} - virtual void process(VideoFrame& videoFrame); + virtual void process(VideoFrame& videoFrame) override; }; } diff --git a/ffmpegthumbnailer/moviedecoder.cpp b/ffmpegthumbnailer/moviedecoder.cpp --- a/ffmpegthumbnailer/moviedecoder.cpp +++ b/ffmpegthumbnailer/moviedecoder.cpp @@ -250,8 +250,6 @@ av_frame_unref(m_pFrame); - int frameFinished = 0; - avcodec_send_packet(m_pVideoCodecContext, m_pPacket); int ret = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame); if (ret == AVERROR(EAGAIN)) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,7 +20,7 @@ add_executable(ffmpegthumbtest ${ffmpegthumbtest_SRCS} ) -target_link_libraries(ffmpegthumbtest Qt5::Core Qt5::Gui KF5::KIOWidgets KF5::KIOCore KF5::I18n KF5::ConfigCore KF5::ConfigGui ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES}) +target_link_libraries(ffmpegthumbtest Qt5::Core Qt5::Gui KF5::KIOWidgets KF5::KIOCore KF5::I18n KF5::ConfigCore KF5::ConfigGui ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} PkgConfig::taglib)