OpenShot Library | libopenshot
0.2.2
|
Go to the documentation of this file.
28 #include "../include/WriterBase.h"
100 cout << fixed << setprecision(2) << boolalpha;
101 cout <<
"----------------------------" << endl;
102 cout <<
"----- File Information -----" << endl;
103 cout <<
"----------------------------" << endl;
107 cout <<
"--> Duration: " <<
info.
duration <<
" Seconds" << endl;
108 cout <<
"--> File Size: " << double(
info.
file_size) / 1024 / 1024 <<
" MB" << endl;
109 cout <<
"----------------------------" << endl;
110 cout <<
"----- Video Attributes -----" << endl;
111 cout <<
"----------------------------" << endl;
112 cout <<
"--> Width: " <<
info.
width << endl;
113 cout <<
"--> Height: " <<
info.
height << endl;
119 cout <<
"--> Video Codec: " <<
info.
vcodec << endl;
125 cout <<
"----------------------------" << endl;
126 cout <<
"----- Audio Attributes -----" << endl;
127 cout <<
"----------------------------" << endl;
128 cout <<
"--> Audio Codec: " <<
info.
acodec << endl;
135 cout <<
"----------------------------" << endl;
154 stringstream filesize_stream;
156 root[
"file_size"] = filesize_stream.str();
160 root[
"fps"] = Json::Value(Json::objectValue);
164 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
167 root[
"display_ratio"] = Json::Value(Json::objectValue);
171 stringstream video_length_stream;
173 root[
"video_length"] = video_length_stream.str();
175 root[
"video_timebase"] = Json::Value(Json::objectValue);
186 root[
"audio_timebase"] = Json::Value(Json::objectValue);
200 bool success = reader.parse( value, root );
203 throw InvalidJSON(
"JSON could not be parsed (or is invalid)",
"");
213 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)",
"");
221 if (!root[
"has_video"].isNull())
223 if (!root[
"has_audio"].isNull())
225 if (!root[
"has_single_image"].isNull())
227 if (!root[
"duration"].isNull())
229 if (!root[
"file_size"].isNull())
231 if (!root[
"height"].isNull())
233 if (!root[
"width"].isNull())
235 if (!root[
"pixel_format"].isNull())
237 if (!root[
"fps"].isNull() && root[
"fps"].isObject()) {
238 if (!root[
"fps"][
"num"].isNull())
240 if (!root[
"fps"][
"den"].isNull())
243 if (!root[
"video_bit_rate"].isNull())
245 if (!root[
"pixel_ratio"].isNull() && root[
"pixel_ratio"].isObject()) {
246 if (!root[
"pixel_ratio"][
"num"].isNull())
248 if (!root[
"pixel_ratio"][
"den"].isNull())
251 if (!root[
"display_ratio"].isNull() && root[
"display_ratio"].isObject()) {
252 if (!root[
"display_ratio"][
"num"].isNull())
254 if (!root[
"display_ratio"][
"den"].isNull())
257 if (!root[
"vcodec"].isNull())
259 if (!root[
"video_length"].isNull())
261 if (!root[
"video_stream_index"].isNull())
263 if (!root[
"video_timebase"].isNull() && root[
"video_timebase"].isObject()) {
264 if (!root[
"video_timebase"][
"num"].isNull())
266 if (!root[
"video_timebase"][
"den"].isNull())
269 if (!root[
"interlaced_frame"].isNull())
271 if (!root[
"top_field_first"].isNull())
273 if (!root[
"acodec"].isNull())
276 if (!root[
"audio_bit_rate"].isNull())
278 if (!root[
"sample_rate"].isNull())
280 if (!root[
"channels"].isNull())
282 if (!root[
"channel_layout"].isNull())
284 if (!root[
"audio_stream_index"].isNull())
286 if (!root[
"audio_timebase"].isNull() && root[
"audio_timebase"].isObject()) {
287 if (!root[
"audio_timebase"][
"num"].isNull())
289 if (!root[
"audio_timebase"][
"den"].isNull())
bool has_single_image
Determines if this file only contains a single image.
int sample_rate
The number of audio samples per second (44100 is a common sample rate)
int64_t video_length
The number of frames in the video stream.
int video_bit_rate
The bit rate of the video stream (in bytes)
string vcodec
The name of the video codec used to encode / decode the video stream.
This namespace is the default namespace for all code in the openshot library.
string acodec
The name of the audio codec used to encode / decode the video stream.
int audio_bit_rate
The bit rate of the audio stream (in bytes)
int channels
The number of audio channels used in the audio stream.
Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square)
This class represents a fraction.
ChannelLayout channel_layout
The channel layout (mono, stereo, 5 point surround, etc...)
Fraction audio_timebase
The audio timebase determines how long each audio packet should be played.
void SetJsonValue(Json::Value root)
Load Json::JsonValue into this object.
int audio_bit_rate
The bit rate of the audio stream (in bytes)
int video_stream_index
The index of the video stream.
float duration
Length of time (in seconds)
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)
int width
The width of the video (in pixesl)
ReaderInfo info
Information about the current media file.
Fraction video_timebase
The video timebase determines how long each frame stays on the screen.
int width
The width of the video (in pixels)
string acodec
The name of the audio codec used to encode / decode the video stream.
void DisplayInfo()
Display file information in the standard output stream (stdout)
int64_t video_length
The number of frames in the video stream.
int height
The height of the video (in pixels)
int num
Numerator for the fraction.
bool top_field_first
Which interlaced field should be displayed first.
int64_t file_size
Size of file (in bytes)
Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3)
void CopyReaderInfo(ReaderBase *reader)
This method copy's the info struct of a reader, and sets the writer with the same info.
int den
Denominator for the fraction.
string Json()
Get and Set JSON methods.
float duration
Length of time (in seconds)
Json::Value JsonValue()
Generate Json::JsonValue for this object.
bool has_audio
Determines if this file has an audio stream.
Exception for invalid JSON.
int64_t file_size
Size of file (in bytes)
Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square)
bool has_single_image
Determines if this file only contains a single image.
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 audio_stream_index
The index of the audio stream.
int pixel_format
The pixel format (i.e. YUV420P, RGB24, etc...)
bool has_video
Determines if this file has a video stream.
string vcodec
The name of the video codec used to encode / decode the video stream.
bool has_audio
Determines if this file has an audio stream.
int height
The height of the video (in pixels)
Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
ChannelLayout channel_layout
The channel layout (mono, stereo, 5 point surround, etc...)
Fraction video_timebase
The video timebase determines how long each frame stays on the screen.
int video_bit_rate
The bit rate of the video stream (in bytes)
This abstract class is the base class, used by all readers in libopenshot.
bool interlaced_frame
Are the contents of this frame interlaced.
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)
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround,...
int video_stream_index
The index of the video stream.
int audio_stream_index
The index of the audio stream.
Fraction audio_timebase
The audio timebase determines how long each audio packet should be played.
WriterInfo info
Information about the current media file.
int channels
The number of audio channels used in the audio stream.
void SetJson(string value)
Load JSON string into this object.
WriterBase()
Constructor for WriterBase class, many things are initialized here.