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())
int channels
The number of audio channels used in the audio stream.
int num
Numerator for the fraction.
WriterInfo info
Information about the current media file.
void SetJsonValue(Json::Value root)
Load Json::JsonValue into this object.
void SetJson(string value)
Load JSON string into this object.
int video_bit_rate
The bit rate of the video stream (in bytes)
ChannelLayout channel_layout
The channel layout (mono, stereo, 5 point surround, etc...)
Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) ...
int width
The width of the video (in pixesl)
void CopyReaderInfo(ReaderBase *reader)
This method copy's the info struct of a reader, and sets the writer with the same info...
int64_t video_length
The number of frames in the video stream.
string acodec
The name of the audio codec used to encode / decode the video stream.
float duration
Length of time (in seconds)
void DisplayInfo()
Display file information in the standard output stream (stdout)
string acodec
The name of the audio codec used to encode / decode the video stream.
string vcodec
The name of the video codec used to encode / decode the video stream.
WriterBase()
Constructor for WriterBase class, many things are initialized here.
This abstract class is the base class, used by all readers in libopenshot.
int width
The width of the video (in pixels)
int audio_bit_rate
The bit rate of the audio stream (in bytes)
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)
int64_t file_size
Size of file (in bytes)
Fraction audio_timebase
The audio timebase determines how long each audio packet should be played.
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.
float duration
Length of time (in seconds)
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)
bool top_field_first
Which interlaced field should be displayed first.
This class represents a fraction.
int pixel_format
The pixel format (i.e. YUV420P, RGB24, etc...)
Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) ...
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...
bool interlaced_frame
Are the contents of this frame interlaced.
ReaderInfo info
Information about the current media file.
int sample_rate
The number of audio samples per second (44100 is a common sample rate)
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.
bool has_video
Determines if this file has a video stream.
Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) ...
Json::Value JsonValue()
Generate Json::JsonValue for this object.
This namespace is the default namespace for all code in the openshot library.
int audio_stream_index
The index of the audio stream.
Exception for invalid JSON.
int pixel_format
The pixel format (i.e. YUV420P, RGB24, etc...)
int video_bit_rate
The bit rate of the video stream (in bytes)
bool has_audio
Determines if this file has an audio stream.
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.
ChannelLayout channel_layout
The channel layout (mono, stereo, 5 point surround, etc...)
int height
The height of the video (in pixels)
int den
Denominator for the fraction.
int channels
The number of audio channels used in the audio stream.
string Json()
Get and Set JSON methods.
int video_stream_index
The index of the video stream.
bool has_single_image
Determines if this file only contains a single image.
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)