31 #include "../include/Profiles.h" 40 bool read_file =
false;
57 QFile inputFile(path.c_str());
58 if (inputFile.open(QIODevice::ReadOnly))
60 QTextStream in(&inputFile);
63 QString line = in.readLine();
65 if (line.length() <= 0)
69 QStringList parts = line.split(
"=" );
70 std::string setting = parts[0].toStdString();
71 std::string value = parts[1].toStdString();
75 if (setting ==
"description")
77 else if (setting ==
"frame_rate_num") {
78 std::stringstream(value) >> value_int;
81 else if (setting ==
"frame_rate_den") {
82 std::stringstream(value) >> value_int;
85 else if (setting ==
"width") {
86 std::stringstream(value) >> value_int;
89 else if (setting ==
"height") {
90 std::stringstream(value) >> value_int;
93 else if (setting ==
"progressive") {
94 std::stringstream(value) >> value_int;
97 else if (setting ==
"sample_aspect_num") {
98 std::stringstream(value) >> value_int;
101 else if (setting ==
"sample_aspect_den") {
102 std::stringstream(value) >> value_int;
105 else if (setting ==
"display_aspect_num") {
106 std::stringstream(value) >> value_int;
109 else if (setting ==
"display_aspect_den") {
110 std::stringstream(value) >> value_int;
113 else if (setting ==
"colorspace") {
114 std::stringstream(value) >> value_int;
123 catch (
const std::exception& e)
126 throw InvalidFile(
"Profile could not be found or loaded (or is invalid).", path);
132 throw InvalidFile(
"Profile could not be found or loaded (or is invalid).", path);
150 root[
"fps"] = Json::Value(Json::objectValue);
153 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
156 root[
"display_ratio"] = Json::Value(Json::objectValue);
175 catch (
const std::exception& e)
178 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
185 if (!root[
"height"].isNull())
187 if (!root[
"width"].isNull())
189 if (!root[
"pixel_format"].isNull())
191 if (!root[
"fps"].isNull()) {
195 if (!root[
"pixel_ratio"].isNull()) {
199 if (!root[
"display_ratio"].isNull()) {
203 if (!root[
"interlaced_frame"].isNull())
int num
Numerator for the fraction.
ProfileInfo info
Profile data stored here.
void SetJson(const std::string value)
Load JSON string into this object.
std::string description
The description of this profile.
const Json::Value stringToJson(const std::string value)
Profile(std::string path)
Constructor for Profile.
std::string Json() const
Get and Set JSON methods.
Exception for files that can not be found or opened.
Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) ...
Json::Value JsonValue() const
Generate Json::Value for this object.
int width
The width of the video (in pixels)
Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
int pixel_format
The pixel format (i.e. YUV420P, RGB24, etc...)
int height
The height of the video (in pixels)
This namespace is the default namespace for all code in the openshot library.
Exception for invalid JSON.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) ...
int den
Denominator for the fraction.