28 #include "../include/ReaderBase.h"
30 using namespace openshot;
68 cout << fixed << setprecision(2) << boolalpha;
69 cout <<
"----------------------------" << endl;
70 cout <<
"----- File Information -----" << endl;
71 cout <<
"----------------------------" << endl;
75 cout <<
"--> Duration: " <<
info.
duration <<
" Seconds" << endl;
76 cout <<
"--> File Size: " << double(
info.
file_size) / 1024 / 1024 <<
" MB" << endl;
77 cout <<
"----------------------------" << endl;
78 cout <<
"----- Video Attributes -----" << endl;
79 cout <<
"----------------------------" << endl;
80 cout <<
"--> Width: " <<
info.
width << endl;
87 cout <<
"--> Video Codec: " <<
info.
vcodec << endl;
93 cout <<
"----------------------------" << endl;
94 cout <<
"----- Audio Attributes -----" << endl;
95 cout <<
"----------------------------" << endl;
96 cout <<
"--> Audio Codec: " <<
info.
acodec << endl;
103 cout <<
"----------------------------" << endl;
104 cout <<
"--------- Metadata ---------" << endl;
105 cout <<
"----------------------------" << endl;
108 map<string, string>::iterator it;
110 cout <<
"--> " << it->first <<
": " << it->second << endl;
122 stringstream filesize_stream;
124 root[
"file_size"] = filesize_stream.str();
128 root[
"fps"] = Json::Value(Json::objectValue);
132 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
135 root[
"display_ratio"] = Json::Value(Json::objectValue);
139 stringstream video_length_stream;
141 root[
"video_length"] = video_length_stream.str();
143 root[
"video_timebase"] = Json::Value(Json::objectValue);
154 root[
"audio_timebase"] = Json::Value(Json::objectValue);
159 root[
"metadata"] = Json::Value(Json::objectValue);
160 map<string, string>::iterator it;
162 root[
"metadata"][it->first] = it->second;
172 if (!root[
"has_video"].isNull())
174 if (!root[
"has_audio"].isNull())
176 if (!root[
"has_single_image"].isNull())
178 if (!root[
"duration"].isNull())
180 if (!root[
"file_size"].isNull())
181 info.
file_size = atoll(root[
"file_size"].asString().c_str());
182 if (!root[
"height"].isNull())
184 if (!root[
"width"].isNull())
186 if (!root[
"pixel_format"].isNull())
188 if (!root[
"fps"].isNull() && root[
"fps"].isObject()) {
189 if (!root[
"fps"][
"num"].isNull())
191 if (!root[
"fps"][
"den"].isNull())
194 if (!root[
"video_bit_rate"].isNull())
196 if (!root[
"pixel_ratio"].isNull() && root[
"pixel_ratio"].isObject()) {
197 if (!root[
"pixel_ratio"][
"num"].isNull())
199 if (!root[
"pixel_ratio"][
"den"].isNull())
202 if (!root[
"display_ratio"].isNull() && root[
"display_ratio"].isObject()) {
203 if (!root[
"display_ratio"][
"num"].isNull())
205 if (!root[
"display_ratio"][
"den"].isNull())
208 if (!root[
"vcodec"].isNull())
210 if (!root[
"video_length"].isNull())
212 if (!root[
"video_stream_index"].isNull())
214 if (!root[
"video_timebase"].isNull() && root[
"video_timebase"].isObject()) {
215 if (!root[
"video_timebase"][
"num"].isNull())
217 if (!root[
"video_timebase"][
"den"].isNull())
220 if (!root[
"interlaced_frame"].isNull())
222 if (!root[
"top_field_first"].isNull())
224 if (!root[
"acodec"].isNull())
227 if (!root[
"audio_bit_rate"].isNull())
229 if (!root[
"sample_rate"].isNull())
231 if (!root[
"channels"].isNull())
233 if (!root[
"channel_layout"].isNull())
235 if (!root[
"audio_stream_index"].isNull())
237 if (!root[
"audio_timebase"].isNull() && root[
"audio_timebase"].isObject()) {
238 if (!root[
"audio_timebase"][
"num"].isNull())
240 if (!root[
"audio_timebase"][
"den"].isNull())
243 if (!root[
"metadata"].isNull() && root[
"metadata"].isObject()) {
244 for( Json::Value::iterator itr = root[
"metadata"].begin() ; itr != root[
"metadata"].end() ; itr++ ) {
245 string key = itr.key().asString();
int num
Numerator for the fraction.
ChannelLayout channel_layout
The channel layout (mono, stereo, 5 point surround, etc...)
int width
The width of the video (in pixesl)
ReaderBase()
Constructor for the base reader, where many things are initialized.
float duration
Length of time (in seconds)
string acodec
The name of the audio codec used to encode / decode the video stream.
void SetClip(ClipBase *clip)
Set parent clip object of this reader.
bool has_video
Determines if this file has a video stream.
Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) ...
int64_t file_size
Size of file (in bytes)
int audio_bit_rate
The bit rate of the audio stream (in bytes)
bool has_audio
Determines if this file has an audio stream.
int audio_stream_index
The index of the audio stream.
int64_t video_length
The number of frames in the video stream.
int height
The height of the video (in pixels)
ClipBase * GetClip()
Parent clip object of this reader (which can be unparented and NULL)
This class represents a fraction.
bool has_single_image
Determines if this file only contains a single image.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround...
This abstract class is the base class, used by all clips in libopenshot.
virtual Json::Value JsonValue()=0
Generate Json::JsonValue for this object.
virtual void SetJsonValue(Json::Value root)=0
Load Json::JsonValue into this object.
ReaderInfo info
Information about the current media file.
Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
Fraction video_timebase
The video timebase determines how long each frame stays on the screen.
std::map< string, string > metadata
An optional map/dictionary of metadata for this reader.
Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) ...
int pixel_format
The pixel format (i.e. YUV420P, RGB24, etc...)
int video_bit_rate
The bit rate of the video stream (in bytes)
Fraction audio_timebase
The audio timebase determines how long each audio packet should be played.
string vcodec
The name of the video codec used to encode / decode the video stream.
void DisplayInfo()
Display file information in the standard output stream (stdout)
int den
Denominator for the fraction.
int channels
The number of audio channels used in the audio stream.
int video_stream_index
The index of the video stream.
double ToDouble()
Return this fraction as a double (i.e. 1/2 = 0.5)
int sample_rate
The number of audio samples per second (44100 is a common sample rate)