31 #include "../include/ReaderBase.h"
71 std::cout << std::fixed << std::setprecision(2) << std::boolalpha;
72 std::cout <<
"----------------------------" << std::endl;
73 std::cout <<
"----- File Information -----" << std::endl;
74 std::cout <<
"----------------------------" << std::endl;
75 std::cout <<
"--> Has Video: " <<
info.
has_video << std::endl;
76 std::cout <<
"--> Has Audio: " <<
info.
has_audio << std::endl;
78 std::cout <<
"--> Duration: " <<
info.
duration <<
" Seconds" << std::endl;
79 std::cout <<
"--> File Size: " << double(
info.
file_size) / 1024 / 1024 <<
" MB" << std::endl;
80 std::cout <<
"----------------------------" << std::endl;
81 std::cout <<
"----- Video Attributes -----" << std::endl;
82 std::cout <<
"----------------------------" << std::endl;
83 std::cout <<
"--> Width: " <<
info.
width << std::endl;
84 std::cout <<
"--> Height: " <<
info.
height << std::endl;
87 std::cout <<
"--> Video Bit Rate: " <<
info.
video_bit_rate/1000 <<
" kb/s" << std::endl;
90 std::cout <<
"--> Video Codec: " <<
info.
vcodec << std::endl;
91 std::cout <<
"--> Video Length: " <<
info.
video_length <<
" Frames" << std::endl;
96 std::cout <<
"----------------------------" << std::endl;
97 std::cout <<
"----- Audio Attributes -----" << std::endl;
98 std::cout <<
"----------------------------" << std::endl;
99 std::cout <<
"--> Audio Codec: " <<
info.
acodec << std::endl;
100 std::cout <<
"--> Audio Bit Rate: " <<
info.
audio_bit_rate/1000 <<
" kb/s" << std::endl;
101 std::cout <<
"--> Sample Rate: " <<
info.
sample_rate <<
" Hz" << std::endl;
102 std::cout <<
"--> # of Channels: " <<
info.
channels << std::endl;
106 std::cout <<
"----------------------------" << std::endl;
107 std::cout <<
"--------- Metadata ---------" << std::endl;
108 std::cout <<
"----------------------------" << std::endl;
112 std::cout <<
"--> " << it.first <<
": " << it.second << std::endl;
124 std::stringstream filesize_stream;
126 root[
"file_size"] = filesize_stream.str();
130 root[
"fps"] = Json::Value(Json::objectValue);
134 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
137 root[
"display_ratio"] = Json::Value(Json::objectValue);
141 std::stringstream video_length_stream;
143 root[
"video_length"] = video_length_stream.str();
145 root[
"video_timebase"] = Json::Value(Json::objectValue);
156 root[
"audio_timebase"] = Json::Value(Json::objectValue);
161 root[
"metadata"] = Json::Value(Json::objectValue);
164 root[
"metadata"][it.first] = it.second;
174 if (!root[
"has_video"].isNull())
176 if (!root[
"has_audio"].isNull())
178 if (!root[
"has_single_image"].isNull())
180 if (!root[
"duration"].isNull())
182 if (!root[
"file_size"].isNull())
184 if (!root[
"height"].isNull())
186 if (!root[
"width"].isNull())
188 if (!root[
"pixel_format"].isNull())
190 if (!root[
"fps"].isNull() && root[
"fps"].isObject()) {
191 if (!root[
"fps"][
"num"].isNull())
193 if (!root[
"fps"][
"den"].isNull())
196 if (!root[
"video_bit_rate"].isNull())
198 if (!root[
"pixel_ratio"].isNull() && root[
"pixel_ratio"].isObject()) {
199 if (!root[
"pixel_ratio"][
"num"].isNull())
201 if (!root[
"pixel_ratio"][
"den"].isNull())
204 if (!root[
"display_ratio"].isNull() && root[
"display_ratio"].isObject()) {
205 if (!root[
"display_ratio"][
"num"].isNull())
207 if (!root[
"display_ratio"][
"den"].isNull())
210 if (!root[
"vcodec"].isNull())
212 if (!root[
"video_length"].isNull())
214 if (!root[
"video_stream_index"].isNull())
216 if (!root[
"video_timebase"].isNull() && root[
"video_timebase"].isObject()) {
217 if (!root[
"video_timebase"][
"num"].isNull())
219 if (!root[
"video_timebase"][
"den"].isNull())
222 if (!root[
"interlaced_frame"].isNull())
224 if (!root[
"top_field_first"].isNull())
226 if (!root[
"acodec"].isNull())
229 if (!root[
"audio_bit_rate"].isNull())
231 if (!root[
"sample_rate"].isNull())
233 if (!root[
"channels"].isNull())
235 if (!root[
"channel_layout"].isNull())
237 if (!root[
"audio_stream_index"].isNull())
239 if (!root[
"audio_timebase"].isNull() && root[
"audio_timebase"].isObject()) {
240 if (!root[
"audio_timebase"][
"num"].isNull())
242 if (!root[
"audio_timebase"][
"den"].isNull())
245 if (!root[
"metadata"].isNull() && root[
"metadata"].isObject()) {
246 for( Json::Value::const_iterator itr = root[
"metadata"].begin() ; itr != root[
"metadata"].end() ; itr++ ) {
247 std::string key = itr.key().asString();
This abstract class is the base class, used by all clips in libopenshot.
This class represents a fraction.
int num
Numerator for the fraction.
double ToDouble()
Return this fraction as a double (i.e. 1/2 = 0.5)
int den
Denominator for the fraction.
openshot::ClipBase * parent
openshot::ReaderInfo info
Information about the current media file.
openshot::ClipBase * GetClip()
Parent clip object of this reader (which can be unparented and NULL)
void SetClip(openshot::ClipBase *clip)
Set parent clip object of this reader.
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.
void DisplayInfo()
Display file information in the standard output stream (stdout)
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,...
int audio_bit_rate
The bit rate of the audio stream (in bytes)
int video_bit_rate
The bit rate of the video stream (in bytes)
bool has_single_image
Determines if this file only contains a single image.
float duration
Length of time (in seconds)
openshot::Fraction audio_timebase
The audio timebase determines how long each audio packet should be played.
int width
The width of the video (in pixesl)
int channels
The number of audio channels used in the audio stream.
openshot::Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
openshot::Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3)
int height
The height of the video (in pixels)
int pixel_format
The pixel format (i.e. YUV420P, RGB24, etc...)
int64_t video_length
The number of frames in the video stream.
std::string acodec
The name of the audio codec used to encode / decode the video stream.
std::map< std::string, std::string > metadata
An optional map/dictionary of metadata for this reader.
std::string vcodec
The name of the video codec used to encode / decode the video stream.
openshot::Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square)
openshot::ChannelLayout channel_layout
The channel layout (mono, stereo, 5 point surround, etc...)
bool has_video
Determines if this file has a video stream.
bool has_audio
Determines if this file has an audio stream.
openshot::Fraction video_timebase
The video timebase determines how long each frame stays on the screen.
int video_stream_index
The index of the video stream.
int sample_rate
The number of audio samples per second (44100 is a common sample rate)
int audio_stream_index
The index of the audio stream.
int64_t file_size
Size of file (in bytes)