File indexing completed on 2025-01-19 04:22:52
0001 /* 0002 SPDX-FileCopyrightText: 2010 Dirk Vanden Boer <dirk.vdb@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef VIDEO_THUMBNAILER_H 0008 #define VIDEO_THUMBNAILER_H 0009 0010 #include <string> 0011 #include <vector> 0012 #include <map> 0013 #include <inttypes.h> 0014 0015 #include "ifilter.h" 0016 #include "histogram.h" 0017 #include <QString> 0018 #include <QImage> 0019 0020 0021 namespace ffmpegthumbnailer 0022 { 0023 0024 struct VideoFrame; 0025 class ImageWriter; 0026 class MovieDecoder; 0027 0028 class VideoThumbnailer 0029 { 0030 public: 0031 VideoThumbnailer(); 0032 VideoThumbnailer(int thumbnailSize, bool workaroundIssues, bool maintainAspectRatio, bool smartFrameSelection); 0033 ~VideoThumbnailer(); 0034 0035 void generateThumbnail(const QString& videoFile, QImage &image); 0036 0037 void setThumbnailSize(int size); 0038 void setSeekPercentage(int percentage); 0039 void setSeekTime(const QString& seekTime); 0040 void setWorkAroundIssues(bool workAround); 0041 void setMaintainAspectRatio(bool enabled); 0042 void setSmartFrameSelection(bool enabled); 0043 void addFilter(IFilter* filter); 0044 void removeFilter(IFilter* filter); 0045 void clearFilters(); 0046 0047 private: 0048 void generateThumbnail(const QString& videoFile, ImageWriter& imageWriter, QImage& image); 0049 void generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame); 0050 0051 QString getMimeType(const QString& videoFile); 0052 QString getExtension(const QString& videoFilename); 0053 0054 void generateHistogram(const VideoFrame& videoFrame, Histogram<int>& histogram); 0055 int getBestThumbnailIndex(std::vector<VideoFrame>& videoFrames, const std::vector<Histogram<int> >& histograms); 0056 void applyFilters(VideoFrame& frameData); 0057 0058 private: 0059 int m_ThumbnailSize; 0060 quint16 m_SeekPercentage; 0061 bool m_OverlayFilmStrip; 0062 bool m_WorkAroundIssues; 0063 bool m_MaintainAspectRatio; 0064 bool m_SmartFrameSelection; 0065 QString m_SeekTime; 0066 std::vector<IFilter*> m_Filters; 0067 }; 0068 0069 } 0070 0071 #endif