aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
blob: ee76a8dc2a41631e48d0840789a9c83008912868 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef VIDNAIL_H
#define VIDNAIL_H

extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}

class VidNail;

struct vFrame {
    vFrame() : *width(0), *height(0) {}
    vFrame(int *width, int *height : width(width), height(height) {}
    int *width;
    int *height;
};

public:

    QString getCodec();
    void goto(int timeInSeconds);
    void readVideoFrame();
    void getScaledVideoFrame(int scaledSize, vFrame& vFrame);

    int getWidth();
    int getHeight();
    int getLength();

    void makeThumbnail(const QString& videoFile, QImage &image);
    void setThumbnailSize(int size);
    void setPercentage(int percent);
    void setTime(const QString& Time);

    void writeVidNail(vFrame& frame, QImage& image);


 private:

    bool readVideoPacket();
    bool getVideoPacket();
    void scaleVideo(int scaledSize, int& scaledWidth, int& scaledHeight);
    void createVFrame(AVFrame *vFrame, quint8 *frameBuffer, int width, int height);
    void calculateDimensions(int size);
    void generateThumbnail(const QString& videoFile, ImageWriter& imageWriter, QImage& 
image);
    QString getMimeType(const QString& videoFile);
    QString getExtension(const QString& videoFilename);


 private:
     int                    videoStream;
     AVFormatContext        *inputVideoFormatContext;
     AVCodecContext         *inputvideoCodecContext;
     AVCodec                *inputVideoCodec;
     AVStream               *inputVideoStream;
     AVFrame                *inputVideoFrame;
     quint8                 *inputFrameBuffer;
     AVPacket               *videoPacket;


#endif // VIDNAIL_H
bgstack15