30 info.has_video =
false;
31 info.has_audio =
false;
32 info.has_single_image =
false;
37 info.pixel_format = -1;
39 info.video_bit_rate = 0;
43 info.video_length = 0;
44 info.video_stream_index = -1;
46 info.interlaced_frame =
false;
47 info.top_field_first =
true;
49 info.audio_bit_rate = 0;
53 info.audio_stream_index = -1;
65 *out << std::fixed << std::setprecision(2) << std::boolalpha;
66 *out <<
"----------------------------" << std::endl;
67 *out <<
"----- File Information -----" << std::endl;
68 *out <<
"----------------------------" << std::endl;
69 *out <<
"--> Has Video: " <<
info.has_video << std::endl;
70 *out <<
"--> Has Audio: " <<
info.has_audio << std::endl;
71 *out <<
"--> Has Single Image: " <<
info.has_single_image << std::endl;
72 *out <<
"--> Duration: " <<
info.duration <<
" Seconds" << std::endl;
73 *out <<
"--> File Size: " << double(
info.file_size) / 1024 / 1024 <<
" MB" << std::endl;
74 *out <<
"----------------------------" << std::endl;
75 *out <<
"----- Video Attributes -----" << std::endl;
76 *out <<
"----------------------------" << std::endl;
77 *out <<
"--> Width: " <<
info.width << std::endl;
78 *out <<
"--> Height: " <<
info.height << std::endl;
79 *out <<
"--> Pixel Format: " <<
info.pixel_format << std::endl;
80 *out <<
"--> Frames Per Second: " <<
info.fps.ToDouble() <<
" (" <<
info.fps.num <<
"/" <<
info.fps.den <<
")" << std::endl;
81 *out <<
"--> Video Bit Rate: " <<
info.video_bit_rate/1000 <<
" kb/s" << std::endl;
82 *out <<
"--> Pixel Ratio: " <<
info.pixel_ratio.ToDouble() <<
" (" <<
info.pixel_ratio.num <<
"/" <<
info.pixel_ratio.den <<
")" << std::endl;
83 *out <<
"--> Display Aspect Ratio: " <<
info.display_ratio.ToDouble() <<
" (" <<
info.display_ratio.num <<
"/" <<
info.display_ratio.den <<
")" << std::endl;
84 *out <<
"--> Video Codec: " <<
info.vcodec << std::endl;
85 *out <<
"--> Video Length: " <<
info.video_length <<
" Frames" << std::endl;
86 *out <<
"--> Video Stream Index: " <<
info.video_stream_index << std::endl;
87 *out <<
"--> Video Timebase: " <<
info.video_timebase.ToDouble() <<
" (" <<
info.video_timebase.num <<
"/" <<
info.video_timebase.den <<
")" << std::endl;
88 *out <<
"--> Interlaced: " <<
info.interlaced_frame << std::endl;
89 *out <<
"--> Interlaced: Top Field First: " <<
info.top_field_first << std::endl;
90 *out <<
"----------------------------" << std::endl;
91 *out <<
"----- Audio Attributes -----" << std::endl;
92 *out <<
"----------------------------" << std::endl;
93 *out <<
"--> Audio Codec: " <<
info.acodec << std::endl;
94 *out <<
"--> Audio Bit Rate: " <<
info.audio_bit_rate/1000 <<
" kb/s" << std::endl;
95 *out <<
"--> Sample Rate: " <<
info.sample_rate <<
" Hz" << std::endl;
96 *out <<
"--> # of Channels: " <<
info.channels << std::endl;
97 *out <<
"--> Channel Layout: " <<
info.channel_layout << std::endl;
98 *out <<
"--> Audio Stream Index: " <<
info.audio_stream_index << std::endl;
99 *out <<
"--> Audio Timebase: " <<
info.audio_timebase.ToDouble() <<
" (" <<
info.audio_timebase.num <<
"/" <<
info.audio_timebase.den <<
")" << std::endl;
100 *out <<
"----------------------------" << std::endl;
101 *out <<
"--------- Metadata ---------" << std::endl;
102 *out <<
"----------------------------" << std::endl;
105 for (
auto it :
info.metadata)
106 *out <<
"--> " << it.first <<
": " << it.second << std::endl;
114 root[
"has_video"] =
info.has_video;
115 root[
"has_audio"] =
info.has_audio;
116 root[
"has_single_image"] =
info.has_single_image;
117 root[
"duration"] =
info.duration;
118 root[
"file_size"] =
static_cast<Json::Value::Int64
>(
info.file_size);
119 root[
"height"] =
info.height;
120 root[
"width"] =
info.width;
121 root[
"pixel_format"] =
info.pixel_format;
122 root[
"fps"] = Json::Value(Json::objectValue);
123 root[
"fps"][
"num"] =
info.fps.num;
124 root[
"fps"][
"den"] =
info.fps.den;
125 root[
"video_bit_rate"] =
info.video_bit_rate;
126 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
127 root[
"pixel_ratio"][
"num"] =
info.pixel_ratio.num;
128 root[
"pixel_ratio"][
"den"] =
info.pixel_ratio.den;
129 root[
"display_ratio"] = Json::Value(Json::objectValue);
130 root[
"display_ratio"][
"num"] =
info.display_ratio.num;
131 root[
"display_ratio"][
"den"] =
info.display_ratio.den;
132 root[
"vcodec"] =
info.vcodec;
133 root[
"video_length"] =
static_cast<Json::Value::Int64
>(
info.video_length);
134 root[
"video_stream_index"] =
info.video_stream_index;
135 root[
"video_timebase"] = Json::Value(Json::objectValue);
136 root[
"video_timebase"][
"num"] =
info.video_timebase.num;
137 root[
"video_timebase"][
"den"] =
info.video_timebase.den;
138 root[
"interlaced_frame"] =
info.interlaced_frame;
139 root[
"top_field_first"] =
info.top_field_first;
140 root[
"acodec"] =
info.acodec;
141 root[
"audio_bit_rate"] =
info.audio_bit_rate;
142 root[
"sample_rate"] =
info.sample_rate;
143 root[
"channels"] =
info.channels;
144 root[
"channel_layout"] =
info.channel_layout;
145 root[
"audio_stream_index"] =
info.audio_stream_index;
146 root[
"audio_timebase"] = Json::Value(Json::objectValue);
147 root[
"audio_timebase"][
"num"] =
info.audio_timebase.num;
148 root[
"audio_timebase"][
"den"] =
info.audio_timebase.den;
151 root[
"metadata"] = Json::Value(Json::objectValue);
153 for (
const auto it :
info.metadata)
154 root[
"metadata"][it.first] = it.second;
164 if (!root[
"has_video"].isNull())
165 info.has_video = root[
"has_video"].asBool();
166 if (!root[
"has_audio"].isNull())
167 info.has_audio = root[
"has_audio"].asBool();
168 if (!root[
"has_single_image"].isNull())
169 info.has_single_image = root[
"has_single_image"].asBool();
170 if (!root[
"duration"].isNull())
171 info.duration = root[
"duration"].asDouble();
172 if (!root[
"file_size"].isNull())
173 info.file_size = std::stoll(root[
"file_size"].asString());
174 if (!root[
"height"].isNull())
175 info.height = root[
"height"].asInt();
176 if (!root[
"width"].isNull())
177 info.width = root[
"width"].asInt();
178 if (!root[
"pixel_format"].isNull())
179 info.pixel_format = root[
"pixel_format"].asInt();
180 if (!root[
"fps"].isNull() && root[
"fps"].isObject()) {
181 if (!root[
"fps"][
"num"].isNull())
182 info.fps.num = root[
"fps"][
"num"].asInt();
183 if (!root[
"fps"][
"den"].isNull())
184 info.fps.den = root[
"fps"][
"den"].asInt();
186 if (!root[
"video_bit_rate"].isNull())
187 info.video_bit_rate = root[
"video_bit_rate"].asInt();
188 if (!root[
"pixel_ratio"].isNull() && root[
"pixel_ratio"].isObject()) {
189 if (!root[
"pixel_ratio"][
"num"].isNull())
190 info.pixel_ratio.num = root[
"pixel_ratio"][
"num"].asInt();
191 if (!root[
"pixel_ratio"][
"den"].isNull())
192 info.pixel_ratio.den = root[
"pixel_ratio"][
"den"].asInt();
194 if (!root[
"display_ratio"].isNull() && root[
"display_ratio"].isObject()) {
195 if (!root[
"display_ratio"][
"num"].isNull())
196 info.display_ratio.num = root[
"display_ratio"][
"num"].asInt();
197 if (!root[
"display_ratio"][
"den"].isNull())
198 info.display_ratio.den = root[
"display_ratio"][
"den"].asInt();
200 if (!root[
"vcodec"].isNull())
201 info.vcodec = root[
"vcodec"].asString();
202 if (!root[
"video_length"].isNull())
203 info.video_length = std::stoll(root[
"video_length"].asString());
204 if (!root[
"video_stream_index"].isNull())
205 info.video_stream_index = root[
"video_stream_index"].asInt();
206 if (!root[
"video_timebase"].isNull() && root[
"video_timebase"].isObject()) {
207 if (!root[
"video_timebase"][
"num"].isNull())
208 info.video_timebase.num = root[
"video_timebase"][
"num"].asInt();
209 if (!root[
"video_timebase"][
"den"].isNull())
210 info.video_timebase.den = root[
"video_timebase"][
"den"].asInt();
212 if (!root[
"interlaced_frame"].isNull())
213 info.interlaced_frame = root[
"interlaced_frame"].asBool();
214 if (!root[
"top_field_first"].isNull())
215 info.top_field_first = root[
"top_field_first"].asBool();
216 if (!root[
"acodec"].isNull())
217 info.acodec = root[
"acodec"].asString();
219 if (!root[
"audio_bit_rate"].isNull())
220 info.audio_bit_rate = root[
"audio_bit_rate"].asInt();
221 if (!root[
"sample_rate"].isNull())
222 info.sample_rate = root[
"sample_rate"].asInt();
223 if (!root[
"channels"].isNull())
224 info.channels = root[
"channels"].asInt();
225 if (!root[
"channel_layout"].isNull())
227 if (!root[
"audio_stream_index"].isNull())
228 info.audio_stream_index = root[
"audio_stream_index"].asInt();
229 if (!root[
"audio_timebase"].isNull() && root[
"audio_timebase"].isObject()) {
230 if (!root[
"audio_timebase"][
"num"].isNull())
231 info.audio_timebase.num = root[
"audio_timebase"][
"num"].asInt();
232 if (!root[
"audio_timebase"][
"den"].isNull())
233 info.audio_timebase.den = root[
"audio_timebase"][
"den"].asInt();
235 if (!root[
"metadata"].isNull() && root[
"metadata"].isObject()) {
236 for( Json::Value::const_iterator itr = root[
"metadata"].begin() ; itr != root[
"metadata"].end() ; itr++ ) {
237 std::string key = itr.key().asString();
238 info.metadata[key] = root[
"metadata"][key].asString();
Header file for ClipBase class.
Header file for Frame class.
Header file for JSON class.
Header file for ReaderBase class.
This abstract class is the base class, used by all clips in libopenshot.
This class represents a fraction.
int max_decode_height
Optional maximum decoded frame height (0 disables the limit).
bool apply_orientation_metadata
Apply source orientation metadata while reading frames.
openshot::ReaderInfo info
Information about the current media file.
void SetMaxDecodeSize(int width, int height)
int max_decode_width
Optional maximum decoded frame width (0 disables the limit).
int MaxDecodeWidth() const
Return the current maximum decoded frame width (0 when unlimited).
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
virtual Json::Value JsonValue() const =0
Generate Json::Value for this object.
int MaxDecodeHeight() const
Return the current maximum decoded frame height (0 when unlimited).
bool ApplyOrientationMetadata() const
Return whether readers apply source orientation metadata to returned frames.
void DisplayInfo(std::ostream *out=&std::cout)
Display file information in the standard output stream (stdout).
bool HasMaxDecodeSize() const
Return true when a maximum decoded frame size is active.
openshot::ClipBase * clip
Pointer to the parent clip instance (if any).
openshot::ClipBase * ParentClip()
Parent clip object of this reader (which can be unparented and NULL).
ReaderBase()
Constructor for the base reader, where many things are initialized.
This namespace is the default namespace for all code in the openshot library.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround,...