Loading...
Searching...
No Matches
Caption.h
Go to the documentation of this file.
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef OPENSHOT_CAPTION_EFFECT_H
#define OPENSHOT_CAPTION_EFFECT_H
#include <memory>
#include <string>
#include <vector>
#include <QFont>
#include <QFontMetrics>
#include <QRegularExpression>
#include "../Color.h"
#include "../EffectBase.h"
#include "../Json.h"
#include "../KeyFrame.h"
namespace openshot
{
class Caption : public EffectBase
{
private:
std::vector<QRegularExpressionMatch> matchedCaptions;
std::string caption_text;
QFontMetrics* metrics;
QFont* font;
bool is_dirty;
void init_effect_details();
void process_regex();
public:
Color color;
Color stroke;
Color background;
Keyframe background_alpha;
Keyframe background_corner;
Keyframe background_padding;
Keyframe stroke_width;
Keyframe font_size;
Keyframe font_alpha;
Keyframe line_spacing;
Keyframe left;
Keyframe top;
Keyframe right;
Keyframe fade_in;
Keyframe fade_out;
std::string font_name;
Caption();
Caption(std::string captions);
std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override { return GetFrame(std::make_shared<openshot::Frame>(), frame_number); }
std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) override;
// Get and Set caption data
std::string CaptionText();
void CaptionText(std::string new_caption_text);
// Get and Set JSON methods
std::string Json() const override;
void SetJson(const std::string value) override;
Json::Value JsonValue() const override;
void SetJsonValue(const Json::Value root) override;
std::string PropertiesJSON(int64_t requested_frame) const override;
};
} // namespace openshot
#endif // OPENSHOT_CAPTION_EFFECT_H
openshot::Caption
This class adds captions/text over a video, based on timestamps. You can also animate some limited as...
Definition Caption.h:39
openshot::Caption::PropertiesJSON
std::string PropertiesJSON(int64_t requested_frame) const override
Definition Caption.cpp:454
openshot::Caption::GetFrame
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
openshot::Caption::background_padding
Keyframe background_padding
Background padding.
Definition Caption.h:60
openshot::Caption::Caption
Caption()
Blank constructor, useful when using Json to load the effect properties.
Definition Caption.cpp:30
openshot::Caption::stroke_width
Keyframe stroke_width
Width of text border / stroke.
Definition Caption.h:61
openshot::Caption::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition Caption.cpp:363
openshot::Caption::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition Caption.cpp:408
openshot::Caption::Json
std::string Json() const override
Generate JSON string of this object.
Definition Caption.cpp:356
openshot::Caption::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition Caption.cpp:391
openshot::Caption::font_name
std::string font_name
Font string.
Definition Caption.h:70
openshot::Caption::background
Color background
Color of caption area background.
Definition Caption.h:57
openshot::Caption::font_size
Keyframe font_size
Font size in points.
Definition Caption.h:62
openshot::Caption::font_alpha
Keyframe font_alpha
Font color alpha.
Definition Caption.h:63
openshot::Caption::background_alpha
Keyframe background_alpha
Background color alpha.
Definition Caption.h:58
openshot::Caption::fade_out
Keyframe fade_out
Fade in per caption (# of seconds)
Definition Caption.h:69
openshot::Caption::background_corner
Keyframe background_corner
Background cornder radius.
Definition Caption.h:59
openshot::Caption::fade_in
Keyframe fade_in
Fade in per caption (# of seconds)
Definition Caption.h:68
openshot::Caption::line_spacing
Keyframe line_spacing
Distance between lines (1.0 default / 100%)
Definition Caption.h:64
openshot::Caption::top
Keyframe top
Size of top bar.
Definition Caption.h:66
openshot::Caption::stroke
Color stroke
Color of text border / stroke.
Definition Caption.h:56
openshot::Caption::CaptionText
std::string CaptionText()
Set the caption string to use (see VTT format)
Definition Caption.cpp:69
openshot::Caption::right
Keyframe right
Size of right bar.
Definition Caption.h:67
openshot::Caption::color
Color color
Color of caption text.
Definition Caption.h:55
openshot::Caption::left
Keyframe left
Size of left bar.
Definition Caption.h:65
openshot::Color
This class represents a color (used on the timeline and clips)
Definition Color.h:27
openshot::EffectBase
This abstract class is the base class, used by all effects in libopenshot.
Definition EffectBase.h:53
openshot::Keyframe
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition KeyFrame.h:53
openshot
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29