23 bool read_file =
false;
40 QFile inputFile(
path.c_str());
41 if (inputFile.open(QIODevice::ReadOnly))
43 QTextStream in(&inputFile);
46 QString line = in.readLine();
48 if (line.length() <= 0)
52 QStringList parts = line.split(
"=" );
53 std::string setting = parts[0].toStdString();
54 std::string value = parts[1].toStdString();
58 if (setting ==
"description")
60 else if (setting ==
"frame_rate_num") {
61 std::stringstream(value) >> value_int;
64 else if (setting ==
"frame_rate_den") {
65 std::stringstream(value) >> value_int;
68 else if (setting ==
"width") {
69 std::stringstream(value) >> value_int;
72 else if (setting ==
"height") {
73 std::stringstream(value) >> value_int;
76 else if (setting ==
"progressive") {
77 std::stringstream(value) >> value_int;
80 else if (setting ==
"sample_aspect_num") {
81 std::stringstream(value) >> value_int;
84 else if (setting ==
"sample_aspect_den") {
85 std::stringstream(value) >> value_int;
88 else if (setting ==
"display_aspect_num") {
89 std::stringstream(value) >> value_int;
92 else if (setting ==
"display_aspect_den") {
93 std::stringstream(value) >> value_int;
96 else if (setting ==
"colorspace") {
97 std::stringstream(value) >> value_int;
106 catch (
const std::exception& e)
109 throw InvalidFile(
"Profile could not be found or loaded (or is invalid).",
path);
115 throw InvalidFile(
"Profile could not be found or loaded (or is invalid).",
path);
133 root[
"fps"] = Json::Value(Json::objectValue);
136 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
139 root[
"display_ratio"] = Json::Value(Json::objectValue);
158 catch (
const std::exception& e)
161 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
168 if (!root[
"height"].isNull())
170 if (!root[
"width"].isNull())
172 if (!root[
"pixel_format"].isNull())
174 if (!root[
"fps"].isNull()) {
178 if (!root[
"pixel_ratio"].isNull()) {
182 if (!root[
"display_ratio"].isNull()) {
186 if (!root[
"interlaced_frame"].isNull())
Header file for all Exception classes.
Header file for Profile class.
int num
Numerator for the fraction.
int den
Denominator for the fraction.
Exception for files that can not be found or opened.
Exception for invalid JSON.
Profile(std::string path)
Constructor for Profile.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
std::string Json() const
Generate JSON string of this object.
ProfileInfo info
Profile data stored here.
void SetJson(const std::string value)
Load JSON string into this object.
Json::Value JsonValue() const
Generate Json::Value for this object.
This namespace is the default namespace for all code in the openshot library.
const Json::Value stringToJson(const std::string value)
std::string description
The description of this profile.
int width
The width of the video (in pixels)
Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square)
Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3)
Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
int height
The height of the video (in pixels)
int pixel_format
The pixel format (i.e. YUV420P, RGB24, etc...)