OpenShot Library | libopenshot 0.3.3
Loading...
Searching...
No Matches
Caption.h
Go to the documentation of this file.
1
9// Copyright (c) 2008-2019 OpenShot Studios, LLC
10//
11// SPDX-License-Identifier: LGPL-3.0-or-later
12
13#ifndef OPENSHOT_CAPTION_EFFECT_H
14#define OPENSHOT_CAPTION_EFFECT_H
15
16#include <memory>
17#include <string>
18#include <vector>
19#include <QFont>
20#include <QFontMetrics>
21#include <QRegularExpression>
22#include "../Color.h"
23#include "../EffectBase.h"
24#include "../Json.h"
25#include "../KeyFrame.h"
26
27
28
29namespace openshot
30{
31
38class Caption : public EffectBase
39{
40private:
41 std::vector<QRegularExpressionMatch> matchedCaptions;
42 std::string caption_text;
43 QFontMetrics* metrics;
44 QFont* font;
45 bool is_dirty;
46
48 void init_effect_details();
49
51 void process_regex();
52
53
54public:
70 std::string font_name;
71
73 Caption();
74
78 Caption(std::string captions);
79
86 std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override { return GetFrame(std::make_shared<openshot::Frame>(), frame_number); }
87
97 std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) override;
98
99 // Get and Set caption data
100 std::string CaptionText();
101 void CaptionText(std::string new_caption_text);
102
103 // Get and Set JSON methods
104 std::string Json() const override;
105 void SetJson(const std::string value) override;
106 Json::Value JsonValue() const override;
107 void SetJsonValue(const Json::Value root) override;
108
111 std::string PropertiesJSON(int64_t requested_frame) const override;
112};
113
114} // namespace openshot
115
116#endif // OPENSHOT_CAPTION_EFFECT_H
This class adds captions/text over a video, based on timestamps. You can also animate some limited as...
Definition Caption.h:39
std::string PropertiesJSON(int64_t requested_frame) const override
Definition Caption.cpp:454
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number) override
This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object...
Definition Caption.h:86
Keyframe background_padding
Background padding.
Definition Caption.h:60
Caption()
Blank constructor, useful when using Json to load the effect properties.
Definition Caption.cpp:30
Keyframe stroke_width
Width of text border / stroke.
Definition Caption.h:61
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition Caption.cpp:363
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition Caption.cpp:408
std::string Json() const override
Generate JSON string of this object.
Definition Caption.cpp:356
void SetJson(const std::string value) override
Load JSON string into this object.
Definition Caption.cpp:391
std::string font_name
Font string.
Definition Caption.h:70
Color background
Color of caption area background.
Definition Caption.h:57
Keyframe font_size
Font size in points.
Definition Caption.h:62
Keyframe font_alpha
Font color alpha.
Definition Caption.h:63
Keyframe background_alpha
Background color alpha.
Definition Caption.h:58
Keyframe fade_out
Fade in per caption (# of seconds)
Definition Caption.h:69
Keyframe background_corner
Background cornder radius.
Definition Caption.h:59
Keyframe fade_in
Fade in per caption (# of seconds)
Definition Caption.h:68
Keyframe line_spacing
Distance between lines (1.0 default / 100%)
Definition Caption.h:64
Keyframe top
Size of top bar.
Definition Caption.h:66
Color stroke
Color of text border / stroke.
Definition Caption.h:56
std::string CaptionText()
Set the caption string to use (see VTT format)
Definition Caption.cpp:69
Keyframe right
Size of right bar.
Definition Caption.h:67
Color color
Color of caption text.
Definition Caption.h:55
Keyframe left
Size of left bar.
Definition Caption.h:65
This class represents a color (used on the timeline and clips)
Definition Color.h:27
This abstract class is the base class, used by all effects in libopenshot.
Definition EffectBase.h:54
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition KeyFrame.h:53
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29