41 bool read_file =
false;
58 QFile inputFile(path.c_str());
59 if (inputFile.open(QIODevice::ReadOnly))
61 QTextStream in(&inputFile);
64 QString line = in.readLine();
66 if (line.length() <= 0)
70 QStringList parts = line.split(
"=" );
71 std::string setting = parts[0].toStdString();
72 std::string value = parts[1].toStdString();
76 if (setting ==
"description")
78 else if (setting ==
"frame_rate_num") {
79 std::stringstream(value) >> value_int;
82 else if (setting ==
"frame_rate_den") {
83 std::stringstream(value) >> value_int;
86 else if (setting ==
"width") {
87 std::stringstream(value) >> value_int;
90 else if (setting ==
"height") {
91 std::stringstream(value) >> value_int;
94 else if (setting ==
"progressive") {
95 std::stringstream(value) >> value_int;
98 else if (setting ==
"sample_aspect_num") {
99 std::stringstream(value) >> value_int;
102 else if (setting ==
"sample_aspect_den") {
103 std::stringstream(value) >> value_int;
106 else if (setting ==
"display_aspect_num") {
107 std::stringstream(value) >> value_int;
110 else if (setting ==
"display_aspect_den") {
111 std::stringstream(value) >> value_int;
114 else if (setting ==
"colorspace") {
115 std::stringstream(value) >> value_int;
124 catch (
const std::exception& e)
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);
176 catch (
const std::exception& e)
179 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
186 if (!root[
"height"].isNull())
188 if (!root[
"width"].isNull())
190 if (!root[
"pixel_format"].isNull())
192 if (!root[
"fps"].isNull()) {
196 if (!root[
"pixel_ratio"].isNull()) {
200 if (!root[
"display_ratio"].isNull()) {
204 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
Generate JSON string of this object.
Header file for all Exception classes.
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) ...
Header file for Profile class.
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.