28 #include "../include/Profiles.h" 37 bool read_file =
false;
42 info.description =
"";
45 info.pixel_format = 0;
48 info.pixel_ratio.num = 0;
49 info.pixel_ratio.den = 0;
50 info.display_ratio.num = 0;
51 info.display_ratio.den = 0;
52 info.interlaced_frame =
false;
55 ifstream myfile (path.c_str());
64 getline (myfile, line);
66 if (line.length() <= 0)
70 QString qline(line.c_str());
71 QStringList parts = qline.split(
"=" );
72 string setting = parts[0].toStdString();
73 string value = parts[1].toStdString();
77 if (setting ==
"description")
78 info.description = value;
79 else if (setting ==
"frame_rate_num") {
80 stringstream(value) >> value_int;
81 info.fps.num = value_int;
83 else if (setting ==
"frame_rate_den") {
84 stringstream(value) >> value_int;
85 info.fps.den = value_int;
87 else if (setting ==
"width") {
88 stringstream(value) >> value_int;
89 info.width = value_int;
91 else if (setting ==
"height") {
92 stringstream(value) >> value_int;
93 info.height = value_int;
95 else if (setting ==
"progressive") {
96 stringstream(value) >> value_int;
97 info.interlaced_frame = !(bool)value_int;
99 else if (setting ==
"sample_aspect_num") {
100 stringstream(value) >> value_int;
101 info.pixel_ratio.num = value_int;
103 else if (setting ==
"sample_aspect_den") {
104 stringstream(value) >> value_int;
105 info.pixel_ratio.den = value_int;
107 else if (setting ==
"display_aspect_num") {
108 stringstream(value) >> value_int;
109 info.display_ratio.num = value_int;
111 else if (setting ==
"display_aspect_den") {
112 stringstream(value) >> value_int;
113 info.display_ratio.den = value_int;
115 else if (setting ==
"colorspace") {
116 stringstream(value) >> value_int;
117 info.pixel_format = value_int;
127 throw InvalidFile(
"Profile could not be found or loaded (or is invalid).", path);
133 throw InvalidFile(
"Profile could not be found or loaded (or is invalid).", path);
151 root[
"fps"] = Json::Value(Json::objectValue);
154 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
157 root[
"display_ratio"] = Json::Value(Json::objectValue);
172 bool success = reader.parse( value, root );
175 throw InvalidJSON(
"JSON could not be parsed (or is invalid)",
"");
185 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)",
"");
192 if (!root[
"height"].isNull())
194 if (!root[
"width"].isNull())
196 if (!root[
"pixel_format"].isNull())
198 if (!root[
"fps"].isNull()) {
202 if (!root[
"pixel_ratio"].isNull()) {
206 if (!root[
"display_ratio"].isNull()) {
210 if (!root[
"interlaced_frame"].isNull())
Profile(string path)
Constructor for Profile.
int num
Numerator for the fraction.
ProfileInfo info
Profile data stored here.
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.