File indexing completed on 2025-01-05 03:57:26

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2017-05-25
0007  * Description : a tool to generate video slideshow from images.
0008  *
0009  * SPDX-FileCopyrightText: 2017-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_VIDSLIDE_SETTINGS_H
0016 #define DIGIKAM_VIDSLIDE_SETTINGS_H
0017 
0018 // Qt includes
0019 
0020 #include <QString>
0021 #include <QStringList>
0022 #include <QList>
0023 #include <QUrl>
0024 #include <QSize>
0025 #include <QMap>
0026 #include <QTime>
0027 
0028 // Local includes
0029 
0030 #include "digikam_export.h"
0031 #include "filesaveconflictbox.h"
0032 #include "transitionmngr.h"
0033 #include "effectmngr.h"
0034 #include "frameosdsettings.h"
0035 #include "dinfointerface.h"
0036 
0037 class KConfigGroup;
0038 
0039 namespace Digikam
0040 {
0041 
0042 class DIGIKAM_EXPORT VidSlideSettings
0043 {
0044 public:
0045 
0046     /**
0047      * Images selection mode
0048      */
0049     enum Selection
0050     {
0051         IMAGES = 0,
0052         ALBUMS
0053     };
0054 
0055     /**
0056      * Video player to use
0057      */
0058     enum VidPlayer
0059     {
0060         NOPLAYER = 0,
0061         INTERNAL,
0062         DESKTOP
0063     };
0064 
0065     /**
0066      * Video Codecs
0067      */
0068     enum VidCodec
0069     {
0070         X264 = 0,    ///< https://en.wikipedia.org/wiki/X264
0071         MPEG4,       ///< https://en.wikipedia.org/wiki/MPEG-4
0072         MPEG2,       ///< https://en.wikipedia.org/wiki/MPEG-2
0073         MJPEG,       ///< https://en.wikipedia.org/wiki/Motion_JPEG
0074         FLASH,       ///< https://en.wikipedia.org/wiki/Adobe_Flash
0075         WEBMVP8,     ///< https://en.wikipedia.org/wiki/VP8
0076         THEORA,      ///< https://en.wikipedia.org/wiki/Theora
0077         WMV7,        ///< https://en.wikipedia.org/wiki/Windows_Media_Video
0078         WMV8,        ///< https://en.wikipedia.org/wiki/Windows_Media_Video
0079         WMV9         ///< https://en.wikipedia.org/wiki/Windows_Media_Video
0080     };
0081 
0082     /**
0083      * Video Standards
0084      */
0085     enum VidStd
0086     {
0087         PAL = 0,    ///< 25 FPS
0088         NTSC        ///< 29.97 FPS
0089     };
0090 
0091     /**
0092      * Video types (size of target screen)
0093      * See https://en.wikipedia.org/wiki/List_of_common_resolutions#Digital_TV_standards
0094      *     https://en.wikipedia.org/wiki/Aspect_ratio_(image)
0095      */
0096     enum VidType
0097     {
0098         QVGA = 0,   ///< 320   x 180  - 16:9    - Computer Graphics
0099         VCD1,       ///< 352   x 240  - 7:5     - Digital TV
0100         VCD2,       ///< 352   x 288  - 6:5     - Digital TV
0101         CVD1,       ///< 352   x 480  - 11:15   - Digital TV
0102         CVD2,       ///< 352   x 576  - 11:18   - Digital TV
0103         HVGA,       ///< 480   x 270  - 16:9    - Computer Graphics
0104         SVCD1,      ///< 480   x 480  - 1:1     - Digital TV
0105         SDTV1,      ///< 528   x 480  - 11:10   - Digital TV
0106         SDTV2,      ///< 544   x 480  - 17:15   - Digital TV
0107         EDTV1,      ///< 544   x 576  - 17;18   - Digital TV
0108         SVCD2,      ///< 480   x 576  - 5:6     - Digital TV
0109         EGA,        ///< 640   x 350  - 16:9    - Computer Graphics
0110         VGA,        ///< 640   x 480  - 4:3     - Computer Graphics
0111         SDTV3,      ///< 704   x 480  - 22:15   - Digital TV
0112         EDTV2,      ///< 704   x 576  - 11;9    - Digital TV
0113         DVD1,       ///< 720   x 480  - 3:2     - Digital TV
0114         DVD2,       ///< 720   x 576  - 5:4     - Digital TV
0115         WVGA,       ///< 800   x 450  - 16:9    - Computer Graphics
0116         SVGA,       ///< 800   x 600  - 4:3     - Computer Graphics
0117         DVGA,       ///< 960   x 640  - 3:2     - Computer Graphics
0118         XVGA,       ///< 1024  x 576  - 16:9    - Computer Graphics
0119         HDTV,       ///< 1280  x 720  - 16:9    - Digital TV
0120         WXGA1,      ///< 1280  x 768  - 5:3     - Computer Graphics
0121         WXGA2,      ///< 1280  x 800  - 8:5     - Computer Graphics
0122         SXGA,       ///< 1280  x 1024 - 5:4     - Computer Graphics
0123         SXGAPLUS,   ///< 1400  x 1050 - 4:3     - Computer Graphics
0124         WSXGA,      ///< 1440  x 900  - 8:5     - Computer Graphics
0125         HDPLUS,     ///< 1600  x 900  - 16:9    - Digital TV
0126         UXGA,       ///< 1600  x 1200 - 4:3     - Computer Graphics
0127         WSXGAPLUS,  ///< 1680  x 1050 - 8:5     - Computer Graphics
0128         BLUERAY,    ///< 1920  x 1080 - 19:9    - Digital TV
0129         WUXGA,      ///< 1920  x 1200 - 8:5     - Computer Graphics
0130         TXGA,       ///< 1920  x 1440 - 7:5     - Computer Graphics
0131         QXGA,       ///< 2048  x 1536 - 4:3     - Computer Graphics
0132         UWFHD,      ///< 2560  < 1080 - 21:9    - Computer Graphics
0133         WQHD,       ///< 2560  x 1440 - 16:9    - Computer Graphics
0134         WQXGA,      ///< 2560  x 1600 - 8:5     - Computer Graphics
0135         QSXGA,      ///< 2560  x 2048 - 5:4     - Computer Graphics
0136         QSXGAPLUS,  ///< 2800  x 2100 - 4:3     - Computer Graphics
0137         WQXGAPLUS,  ///< 3200  x 1800 - 16:9    - Computer Graphics
0138         WQSXGA,     ///< 3200  x 2048 - 25:16   - Computer Graphics
0139         QUXGA,      ///< 3200  x 2400 - 4:3     - Computer Graphics
0140         UHD4K,      ///< 3840  x 2160 - 19:9    - Digital TV
0141         WQUXGA,     ///< 3840  x 2400 - 8:5     - Computer Graphics
0142         HXGA,       ///< 4096  x 3072 - 4:3     - Computer Graphics
0143         UHD5K,      ///< 5120  x 2880 - 16:9    - Computer Graphics
0144         WHXGA,      ///< 5120  x 3200 - 8:5     - Computer Graphics
0145         HSXGA,      ///< 5120  x 4096 - 5:4     - Computer Graphics
0146         UHD6K,      ///< 6016  x 3384 - 16:9    - Computer Graphics
0147         WHSXGA,     ///< 6400  x 4096 - 25:16   - Computer Graphics
0148         HUXGA,      ///< 6400  x 4800 - 4:3     - Computer Graphics
0149         UHD8K,      ///< 7680  x 4320 - 16:9    - Digital TV
0150         WHUXGA,     ///< 7680  x 4800 - 8:5     - Computer Graphics
0151         UW10K,      ///< 10240 x 4320 - 21:9    - Computer Graphics
0152         UW16K       ///< 15360 x 8640 - 16:9    - Computer Graphics
0153     };
0154 
0155     /**
0156      * Video rates in bits per seconds.
0157      */
0158     enum VidBitRate
0159     {
0160         VBR04 = 0,  ///< 400000
0161         VBR05,      ///< 500000
0162         VBR10,      ///< 1000000
0163         VBR12,      ///< 1200000
0164         VBR15,      ///< 1500000
0165         VBR20,      ///< 2000000
0166         VBR25,      ///< 2500000
0167         VBR30,      ///< 3000000
0168         VBR40,      ///< 4000000
0169         VBR45,      ///< 4500000
0170         VBR50,      ///< 5000000
0171         VBR60,      ///< 6000000
0172         VBR80       ///< 8000000
0173     };
0174 
0175     /**
0176      * Video Container Formats
0177      */
0178     enum VidFormat
0179     {
0180         AVI = 0,    ///< https://en.wikipedia.org/wiki/Audio_Video_Interleave
0181         MKV,        ///< https://en.wikipedia.org/wiki/Matroska
0182         MP4,        ///< https://en.wikipedia.org/wiki/MPEG-4_Part_14
0183         MPG         ///< https://en.wikipedia.org/wiki/MPEG-2
0184     };
0185 
0186 public:
0187 
0188     explicit VidSlideSettings();
0189     ~VidSlideSettings();
0190 
0191     /**
0192      * Read and write settings in config file between sessions.
0193      */
0194     void  readSettings(KConfigGroup& group);
0195     void  writeSettings(KConfigGroup& group);
0196 
0197     QSize   videoSize()             const;              ///< Return the current video size.
0198     int     videoBitRate()          const;              ///< Return the current video bit rate.
0199     qreal   videoFrameRate()        const;              ///< Return the current video frame rate.
0200     QString videoCodec()            const;              ///< Return the current video ffmpeg codec name.
0201     QString videoFormat()           const;              ///< Return the current video format extension.
0202 
0203     /**
0204      * Helper methods to fill combobox from GUI.
0205      */
0206     static QMap<VidType,    QString> videoTypeNames();
0207     static QMap<VidBitRate, QString> videoBitRateNames();
0208     static QMap<VidStd,     QString> videoStdNames();
0209     static QMap<VidCodec,   QString> videoCodecNames();
0210     static QMap<VidFormat,  QString> videoFormatNames();
0211     static QMap<VidPlayer,  QString> videoPlayerNames();
0212 
0213     static QSize videoSizeFromType(VidType type);       ///< Return the current size from a type of video.
0214     static bool isVideoTVFormat(VidType type);          ///< Return true if type is a video TV format. If false is returned type is computer graphics screen format.
0215 
0216     QStringList defaultFFmpegSearchPaths() const;
0217 
0218 public:
0219 
0220     Selection                         selMode;          ///< Items selection mode
0221 
0222     // -- Generator settings ------
0223 
0224     QList<QUrl>                       inputImages;      ///< Images stream.
0225     QString                           audioTrack;       ///< Soundtrack stream.
0226 
0227     TransitionMngr::TransType         transition;       ///< Transition type between images.
0228 
0229     int                               imgFrames;        ///< Amount of frames by image to encode in video (ex: 125 frames = 5 s at 25 img/s).
0230 
0231     int                               abitRate;         ///< Encoded Audio stream bit rate in bit/s.
0232     VidBitRate                        vbitRate;         ///< Encoded Video stream bit rate in bit/s.
0233     VidStd                            vStandard;        ///< Encoded Video standard => frame rate in img/s.
0234     VidType                           vType;            ///< Encoded video type.
0235     VidCodec                          vCodec;           ///< Encoded video codec.
0236     VidFormat                         vFormat;          ///< Encoded video container format.
0237     EffectMngr::EffectType            vEffect;          ///< Encoded video effect while displaying images.
0238 
0239     FileSaveConflictBox::ConflictRule conflictRule;     ///< Rule to follow if video file already exists.
0240     QString                           outputDir;        ///< Encoded video stream directory.
0241 
0242     // ---------------------
0243 
0244     QString                           tempDir;          ///< To store temporary frames.
0245     QString                           outputFile;       ///< Path to encoded video.
0246     QString                           filesList;        ///< Path to list of frame files to encode.
0247     QString                           outputVideo;      ///< Target video file encoded at end.
0248     VidPlayer                         outputPlayer;     ///< Open video stream in player at end.
0249     QString                           ffmpegPath;       ///< Path to FFmpeg binary.
0250     bool                              equalize;         ///< Equalize filter to applying while encoding video from frames.
0251     int                               strength;         ///< Equalization strength factor.
0252 
0253     // -- FFMpeg features --------
0254 
0255     QMap<QString, QString>            ffmpegCodecs;     ///< Map of FFmpeg codec names and features.
0256     QMap<QString, QString>            ffmpegFormats;    ///< Map of FFmpeg format names and features.
0257     QTime                             soundtrackLength; ///< Duration of the soundtrack.
0258 
0259     FrameOsdSettings                  osdSettings;      ///< On Screen Display parameters.
0260     DInfoInterface*                   iface;            ///< Plugin host interface to handle item properties.
0261 };
0262 
0263 } // namespace Digikam
0264 
0265 #endif // DIGIKAM_VIDSLIDE_SETTINGS_H