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
45813d96
Commit
45813d96
authored
Aug 07, 2020
by
Martin Tobias Holmedahl Sandsmark
Browse files
register our own log handler for ffmpeg using QLoggingCategory
parent
c0241de2
Changes
3
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
45813d96
...
...
@@ -3,7 +3,7 @@ project(ffmpegthumbs)
cmake_minimum_required
(
VERSION 2.8.12 FATAL_ERROR
)
set
(
QT_MIN_VERSION
"5.2.0"
)
find_package
(
ECM
1.0
.0 REQUIRED NO_MODULE
)
find_package
(
ECM
5.14
.0 REQUIRED NO_MODULE
)
set
(
CMAKE_MODULE_PATH
${
ECM_MODULE_PATH
}
${
ECM_KDE_MODULE_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake
)
include
(
FeatureSummary
)
...
...
@@ -11,6 +11,7 @@ include(WriteBasicConfigVersionFile)
include
(
KDEInstallDirs
)
include
(
KDECMakeSettings
)
include
(
KDECompilerSettings NO_POLICY_SCOPE
)
include
(
ECMQtDeclareLoggingCategory
)
find_package
(
Qt5
${
QT_MIN_VERSION
}
CONFIG REQUIRED COMPONENTS Core Gui
)
find_package
(
KF5 REQUIRED COMPONENTS KIO I18n Config
)
...
...
@@ -37,6 +38,8 @@ set( ffmpegthumbs_PART_SRCS
ffmpegthumbnailer/videothumbnailer.cpp
)
ecm_qt_declare_logging_category
(
ffmpegthumbs_PART_SRCS HEADER ffmpegthumbs_debug.h IDENTIFIER ffmpegthumbs_LOG CATEGORY_NAME org.kde.kdemultimedia.ffmpegthumbs DEFAULT_SEVERITY Critical
)
kconfig_add_kcfg_files
(
ffmpegthumbs_PART_SRCS ffmpegthumbnailersettings5.kcfgc
)
add_library
(
ffmpegthumbs MODULE
${
ffmpegthumbs_PART_SRCS
}
)
...
...
ffmpegthumbnailer.cpp
View file @
45813d96
...
...
@@ -17,6 +17,7 @@
#include "ffmpegthumbnailer.h"
#include "ffmpegthumbnailersettings5.h"
#include "ffmpegthumbs_debug.h"
#include <taglib/mp4file.h>
...
...
@@ -24,10 +25,52 @@
#include <QCheckBox>
#include <KLocalizedString>
extern
"C"
{
#include <libavutil/log.h>
}
namespace
{
struct
FFmpegLogHandler
{
static
void
handleMessage
(
void
*
ptr
,
int
level
,
const
char
*
fmt
,
va_list
vargs
)
{
Q_UNUSED
(
ptr
);
const
QString
message
=
QString
::
vasprintf
(
fmt
,
vargs
);
switch
(
level
)
{
case
AV_LOG_PANIC
:
// ffmpeg will crash now
qCCritical
(
ffmpegthumbs_LOG
)
<<
message
;
break
;
case
AV_LOG_FATAL
:
// fatal as in can't decode, not crash
case
AV_LOG_ERROR
:
case
AV_LOG_WARNING
:
qCWarning
(
ffmpegthumbs_LOG
)
<<
message
;
break
;
case
AV_LOG_INFO
:
qCInfo
(
ffmpegthumbs_LOG
)
<<
message
;
break
;
case
AV_LOG_VERBOSE
:
case
AV_LOG_DEBUG
:
qCDebug
(
ffmpegthumbs_LOG
)
<<
message
;
break
;
default:
qCWarning
(
ffmpegthumbs_LOG
)
<<
"unhandled log level"
<<
level
<<
message
;
break
;
}
}
FFmpegLogHandler
()
{
av_log_set_callback
(
&
FFmpegLogHandler
::
handleMessage
);
}
};
}
//namespace
extern
"C"
{
Q_DECL_EXPORT
ThumbCreator
*
new_creator
()
{
// This is a threadsafe way to ensure that we only register it once
static
FFmpegLogHandler
handler
;
return
new
FFMpegThumbnailer
();
}
}
...
...
tests/CMakeLists.txt
View file @
45813d96
...
...
@@ -15,6 +15,7 @@ set(ffmpegthumbtest_SRCS ffmpegthumbtest.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/../ffmpegthumbnailer/imagewriter.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/../ffmpegthumbnailer/videothumbnailer.cpp
)
ecm_qt_declare_logging_category
(
ffmpegthumbtest_SRCS HEADER ffmpegthumbs_debug.h IDENTIFIER ffmpegthumbs_LOG CATEGORY_NAME org.kde.kdemultimedia.ffmpegthumbs DEFAULT_SEVERITY Critical
)
kconfig_add_kcfg_files
(
ffmpegthumbtest_SRCS
${
CMAKE_CURRENT_SOURCE_DIR
}
/../ffmpegthumbnailersettings5.kcfgc
)
...
...
Write
Preview
Supports
Markdown
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