blob: 921007a575818d16029cade8183d785ab4353308 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <utils/filepath.h>
#include <QLabel>
#include <QSize>
#include <QVersionNumber>
QT_BEGIN_NAMESPACE
class QTimer;
QT_END_NAMESPACE
namespace Utils {
class CommandLine;
class FilePath;
class Process;
}
namespace ScreenRecorder {
using FrameRange = std::pair<int, int>;
struct ClipInfo {
Utils::FilePath file;
// ffmpeg terminology
QSize dimensions;
QString codec;
qreal duration = -1; // seconds
qreal rFrameRate = -1; // frames per second
QString pixFmt;
int streamIdex = -1;
int framesCount() const;
qreal secondForFrame(int frame) const;
QString timeStamp(int frame) const;
bool isNull() const;
bool isCompleteArea(const QRect &rect) const;
bool isCompleteRange(FrameRange range) const;
bool isLossless() const;
};
class TimeLabel : public QLabel
{
public:
explicit TimeLabel(const ClipInfo &clipInfo, QWidget *parent = nullptr);
void setFrame(int frame);
int frame() const;
private:
const ClipInfo &m_clipInfo;
int m_frame = -1;
};
class CropSizeWarningIcon : public QWidget
{
public:
enum IconVariant {
StandardVariant,
ToolBarVariant,
};
explicit CropSizeWarningIcon(IconVariant backgroundType, QWidget *parent = nullptr);
void setCropSize(const QSize &size);
protected:
void paintEvent(QPaintEvent*) override;
private:
void updateVisibility();
bool needsWarning() const;
QSize m_cropSize;
const IconVariant m_iconVariant;
QTimer *m_updateTimer;
};
namespace FFmpegUtils {
ClipInfo clipInfo(const Utils::FilePath &path);
int parseFrameProgressFromOutput(const QByteArray &output);
void sendQuitCommand(Utils::Process *proc);
void killFfmpegProcess(Utils::Process *proc);
void logFfmpegCall(const Utils::CommandLine &cmdLn);
void reportError(const Utils::CommandLine &cmdLn, const QByteArray &error);
} // namespace FFmpegUtils
} // namespace ScreenRecorder
|