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);
170 Json::CharReaderBuilder rbuilder;
171 Json::CharReader* reader(rbuilder.newCharReader());
174 bool success = reader->parse( value.c_str(),
175 value.c_str() + value.size(), &root, &errors );
180 throw InvalidJSON(
"JSON could not be parsed (or is invalid)");
187 catch (
const std::exception& e)
190 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
197 if (!root[
"height"].isNull())
199 if (!root[
"width"].isNull())
201 if (!root[
"pixel_format"].isNull())
203 if (!root[
"fps"].isNull()) {
207 if (!root[
"pixel_ratio"].isNull()) {
211 if (!root[
"display_ratio"].isNull()) {
215 if (!root[
"interlaced_frame"].isNull())
int num
Numerator for the fraction.
ProfileInfo info
Profile data stored here.
std::string description
The description of this profile.
Json::Value JsonValue()
Generate Json::JsonValue for this object.
Profile(std::string path)
Constructor for Profile.
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)
Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
std::string Json()
Get and Set JSON methods.
void SetJson(std::string value)
Load JSON string into this object.
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.