28 #include "../include/Profiles.h" 37 bool read_file =
false;
54 QFile inputFile(path.c_str());
55 if (inputFile.open(QIODevice::ReadOnly))
57 QTextStream in(&inputFile);
60 QString line = in.readLine();
62 if (line.length() <= 0)
66 QStringList parts = line.split(
"=" );
67 string setting = parts[0].toStdString();
68 string value = parts[1].toStdString();
72 if (setting ==
"description")
74 else if (setting ==
"frame_rate_num") {
75 stringstream(value) >> value_int;
78 else if (setting ==
"frame_rate_den") {
79 stringstream(value) >> value_int;
82 else if (setting ==
"width") {
83 stringstream(value) >> value_int;
86 else if (setting ==
"height") {
87 stringstream(value) >> value_int;
90 else if (setting ==
"progressive") {
91 stringstream(value) >> value_int;
94 else if (setting ==
"sample_aspect_num") {
95 stringstream(value) >> value_int;
98 else if (setting ==
"sample_aspect_den") {
99 stringstream(value) >> value_int;
102 else if (setting ==
"display_aspect_num") {
103 stringstream(value) >> value_int;
106 else if (setting ==
"display_aspect_den") {
107 stringstream(value) >> value_int;
110 else if (setting ==
"colorspace") {
111 stringstream(value) >> value_int;
123 throw InvalidFile(
"Profile could not be found or loaded (or is invalid).", path);
129 throw InvalidFile(
"Profile could not be found or loaded (or is invalid).", path);
147 root[
"fps"] = Json::Value(Json::objectValue);
150 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
153 root[
"display_ratio"] = Json::Value(Json::objectValue);
168 bool success = reader.parse( value, root );
171 throw InvalidJSON(
"JSON could not be parsed (or is invalid)",
"");
181 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)",
"");
188 if (!root[
"height"].isNull())
190 if (!root[
"width"].isNull())
192 if (!root[
"pixel_format"].isNull())
194 if (!root[
"fps"].isNull()) {
198 if (!root[
"pixel_ratio"].isNull()) {
202 if (!root[
"display_ratio"].isNull()) {
206 if (!root[
"interlaced_frame"].isNull())
Profile(string path)
Constructor for Profile.
int num
Numerator for the fraction.
ProfileInfo info
Profile data stored here.
string description
The description of this profile.
Json::Value JsonValue()
Generate Json::JsonValue for this object.
Exception for files that can not be found or opened.
void SetJsonValue(Json::Value root)
Load Json::JsonValue into this object.
Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) ...
int width
The width of the video (in pixels)
void SetJson(string value)
Load JSON string into this object.
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.
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.
string Json()
Get and Set JSON methods.