Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
FFmpeg Thumbnailer
Commits
d2ab28b9
Commit
d2ab28b9
authored
Jul 19, 2020
by
Heiko Schaefer
Committed by
Elvis Angelaccio
Jul 26, 2020
Browse files
Use embedded cover in MP4 video files
BUG: 408956
parent
7082a722
Changes
6
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
d2ab28b9
...
...
@@ -15,6 +15,7 @@ include(KDECompilerSettings NO_POLICY_SCOPE)
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
)
find_package
(
Taglib
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
...
...
@@ -39,7 +40,7 @@ set( ffmpegthumbs_PART_SRCS
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
}
Taglib::Taglib
)
install
(
FILES ffmpegthumbnailersettings5.kcfg DESTINATION
${
KCFG_INSTALL_DIR
}
)
install
(
TARGETS ffmpegthumbs DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
...
...
cmake/FindTaglib.cmake
0 → 100644
View file @
d2ab28b9
#.rst:
# FindTaglib
#-----------
#
# Try to find the Taglib library.
#
# This will define the following variables:
#
# ``Taglib_FOUND``
# True if the system has the taglib library of at least the minimum
# version specified by the version parameter to find_package()
# ``Taglib_INCLUDE_DIRS``
# The taglib include dirs for use with target_include_directories
# ``Taglib_LIBRARIES``
# The taglib libraries for use with target_link_libraries()
# ``Taglib_VERSION``
# The version of taglib that was found
#
# If ``Taglib_FOUND is TRUE, it will also define the following imported
# target:
#
# ``Taglib::Taglib``
# The Taglib library
#
# Since 5.72.0
#
# SPDX-FileCopyrightText: 2006 Laurent Montel <montel@kde.org>
# SPDX-FileCopyrightText: 2019 Heiko Becker <heirecka@exherbo.org>
# SPDX-FileCopyrightText: 2020 Elvis Angelaccio <elvis.angelaccio@kde.org>
# SPDX-License-Identifier: BSD-3-Clause
find_package
(
PkgConfig QUIET
)
pkg_search_module
(
PC_TAGLIB QUIET taglib
)
find_path
(
Taglib_INCLUDE_DIRS
NAMES tag.h
PATH_SUFFIXES taglib
HINTS
${
PC_TAGLIB_INCLUDEDIR
}
)
find_library
(
Taglib_LIBRARIES
NAMES tag
HINTS
${
PC_TAGLIB_LIBDIR
}
)
set
(
Taglib_VERSION
${
PC_TAGLIB_VERSION
}
)
if
(
Taglib_INCLUDE_DIRS AND NOT Taglib_VERSION
)
if
(
EXISTS
"
${
Taglib_INCLUDE_DIRS
}
/taglib.h"
)
file
(
READ
"
${
Taglib_INCLUDE_DIRS
}
/taglib.h"
TAGLIB_H
)
string
(
REGEX MATCH
"#define TAGLIB_MAJOR_VERSION[ ]+[0-9]+"
TAGLIB_MAJOR_VERSION_MATCH
${
TAGLIB_H
}
)
string
(
REGEX MATCH
"#define TAGLIB_MINOR_VERSION[ ]+[0-9]+"
TAGLIB_MINOR_VERSION_MATCH
${
TAGLIB_H
}
)
string
(
REGEX MATCH
"#define TAGLIB_PATCH_VERSION[ ]+[0-9]+"
TAGLIB_PATCH_VERSION_MATCH
${
TAGLIB_H
}
)
string
(
REGEX REPLACE
".*_MAJOR_VERSION[ ]+(.*)"
"
\\
1"
TAGLIB_MAJOR_VERSION
"
${
TAGLIB_MAJOR_VERSION_MATCH
}
"
)
string
(
REGEX REPLACE
".*_MINOR_VERSION[ ]+(.*)"
"
\\
1"
TAGLIB_MINOR_VERSION
"
${
TAGLIB_MINOR_VERSION_MATCH
}
"
)
string
(
REGEX REPLACE
".*_PATCH_VERSION[ ]+(.*)"
"
\\
1"
TAGLIB_PATCH_VERSION
"
${
TAGLIB_PATCH_VERSION_MATCH
}
"
)
set
(
Taglib_VERSION
"
${
TAGLIB_MAJOR_VERSION
}
.
${
TAGLIB_MINOR_VERSION
}
.
${
TAGLIB_PATCH_VERSION
}
"
)
endif
()
endif
()
include
(
FindPackageHandleStandardArgs
)
find_package_handle_standard_args
(
Taglib
FOUND_VAR
Taglib_FOUND
REQUIRED_VARS
Taglib_LIBRARIES
Taglib_INCLUDE_DIRS
VERSION_VAR
Taglib_VERSION
)
if
(
Taglib_FOUND AND NOT TARGET Taglib::Taglib
)
add_library
(
Taglib::Taglib UNKNOWN IMPORTED
)
set_target_properties
(
Taglib::Taglib PROPERTIES
IMPORTED_LOCATION
"
${
Taglib_LIBRARIES
}
"
INTERFACE_INCLUDE_DIRECTORIES
"
${
Taglib_INCLUDE_DIRS
}
"
)
endif
()
mark_as_advanced
(
Taglib_LIBRARIES Taglib_INCLUDE_DIRS
)
include
(
FeatureSummary
)
set_package_properties
(
Taglib PROPERTIES
URL
"https://taglib.org/"
DESCRIPTION
"A library for reading and editing the meta-data of audio formats"
)
ffmpegthumbnailer.cpp
View file @
d2ab28b9
// Copyright (C) 2010 Dirk Vanden Boer <dirk.vdb@gmail.com>
// Copyright (C) 2020 Heiko Schäfer <heiko@rangun.de>
//
// 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 <taglib/mp4file.h>
#include <QImage>
#include <QCheckBox>
#include <KLocalizedString>
...
...
@@ -44,6 +47,25 @@ FFMpegThumbnailer::~FFMpegThumbnailer()
bool
FFMpegThumbnailer
::
create
(
const
QString
&
path
,
int
width
,
int
/*height*/
,
QImage
&
img
)
{
QByteArray
ba
=
path
.
toLocal8Bit
();
TagLib
::
MP4
::
File
f
(
ba
.
data
(),
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
);
...
...
ffmpegthumbnailer/filmstripfilter.h
View file @
d2ab28b9
...
...
@@ -26,7 +26,7 @@ class FilmStripFilter : public IFilter
{
public:
virtual
~
FilmStripFilter
()
{}
virtual
void
process
(
VideoFrame
&
videoFrame
);
virtual
void
process
(
VideoFrame
&
videoFrame
)
override
;
};
}
...
...
ffmpegthumbnailer/moviedecoder.cpp
View file @
d2ab28b9
...
...
@@ -250,8 +250,6 @@ bool MovieDecoder::decodeVideoPacket()
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
))
{
...
...
tests/CMakeLists.txt
View file @
d2ab28b9
...
...
@@ -20,7 +20,7 @@ kconfig_add_kcfg_files(ffmpegthumbtest_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../ffmpe
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
}
Taglib::Taglib
)
...
...
Elvis Angelaccio
@elvisangelaccio
mentioned in commit
a846c5f8
·
Jul 28, 2020
mentioned in commit
a846c5f8
mentioned in commit a846c5f89ea1718f6170f922e65bdce46ab20508
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment