28 #include "../include/WriterBase.h"
30 using namespace openshot;
68 string arg2_name,
float arg2_value,
69 string arg3_name,
float arg3_value,
70 string arg4_name,
float arg4_value,
71 string arg5_name,
float arg5_value,
72 string arg6_name,
float arg6_value)
79 #pragma omp critical (debug_output)
82 message << fixed << setprecision(4);
83 message << method_name <<
" (";
86 if (arg1_name.length() > 0)
87 message << arg1_name <<
"=" << arg1_value;
89 if (arg2_name.length() > 0)
90 message <<
", " << arg2_name <<
"=" << arg2_value;
92 if (arg3_name.length() > 0)
93 message <<
", " << arg3_name <<
"=" << arg3_value;
95 if (arg4_name.length() > 0)
96 message <<
", " << arg4_name <<
"=" << arg4_value;
98 if (arg5_name.length() > 0)
99 message <<
", " << arg5_name <<
"=" << arg5_value;
101 if (arg6_name.length() > 0)
102 message <<
", " << arg6_name <<
"=" << arg6_value;
105 message <<
")" << endl;
149 cout << fixed << setprecision(2) << boolalpha;
150 cout <<
"----------------------------" << endl;
151 cout <<
"----- File Information -----" << endl;
152 cout <<
"----------------------------" << endl;
156 cout <<
"--> Duration: " <<
info.
duration <<
" Seconds" << endl;
157 cout <<
"--> File Size: " << double(
info.
file_size) / 1024 / 1024 <<
" MB" << endl;
158 cout <<
"----------------------------" << endl;
159 cout <<
"----- Video Attributes -----" << endl;
160 cout <<
"----------------------------" << endl;
161 cout <<
"--> Width: " <<
info.
width << endl;
162 cout <<
"--> Height: " <<
info.
height << endl;
168 cout <<
"--> Video Codec: " <<
info.
vcodec << endl;
174 cout <<
"----------------------------" << endl;
175 cout <<
"----- Audio Attributes -----" << endl;
176 cout <<
"----------------------------" << endl;
177 cout <<
"--> Audio Codec: " <<
info.
acodec << endl;
184 cout <<
"----------------------------" << endl;
203 stringstream filesize_stream;
205 root[
"file_size"] = filesize_stream.str();
209 root[
"fps"] = Json::Value(Json::objectValue);
213 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
216 root[
"display_ratio"] = Json::Value(Json::objectValue);
220 stringstream video_length_stream;
222 root[
"video_length"] = video_length_stream.str();
224 root[
"video_timebase"] = Json::Value(Json::objectValue);
235 root[
"audio_timebase"] = Json::Value(Json::objectValue);
249 bool success = reader.parse( value, root );
252 throw InvalidJSON(
"JSON could not be parsed (or is invalid)",
"");
262 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)",
"");
270 if (!root[
"has_video"].isNull())
272 if (!root[
"has_audio"].isNull())
274 if (!root[
"has_single_image"].isNull())
276 if (!root[
"duration"].isNull())
278 if (!root[
"file_size"].isNull())
280 if (!root[
"height"].isNull())
282 if (!root[
"width"].isNull())
284 if (!root[
"pixel_format"].isNull())
286 if (!root[
"fps"].isNull() && root[
"fps"].isObject()) {
287 if (!root[
"fps"][
"num"].isNull())
289 if (!root[
"fps"][
"den"].isNull())
292 if (!root[
"video_bit_rate"].isNull())
294 if (!root[
"pixel_ratio"].isNull() && root[
"pixel_ratio"].isObject()) {
295 if (!root[
"pixel_ratio"][
"num"].isNull())
297 if (!root[
"pixel_ratio"][
"den"].isNull())
300 if (!root[
"display_ratio"].isNull() && root[
"display_ratio"].isObject()) {
301 if (!root[
"display_ratio"][
"num"].isNull())
303 if (!root[
"display_ratio"][
"den"].isNull())
306 if (!root[
"vcodec"].isNull())
308 if (!root[
"video_length"].isNull())
310 if (!root[
"video_stream_index"].isNull())
312 if (!root[
"video_timebase"].isNull() && root[
"video_timebase"].isObject()) {
313 if (!root[
"video_timebase"][
"num"].isNull())
315 if (!root[
"video_timebase"][
"den"].isNull())
318 if (!root[
"interlaced_frame"].isNull())
320 if (!root[
"top_field_first"].isNull())
322 if (!root[
"acodec"].isNull())
325 if (!root[
"audio_bit_rate"].isNull())
327 if (!root[
"sample_rate"].isNull())
329 if (!root[
"channels"].isNull())
331 if (!root[
"channel_layout"].isNull())
333 if (!root[
"audio_stream_index"].isNull())
335 if (!root[
"audio_timebase"].isNull() && root[
"audio_timebase"].isObject()) {
336 if (!root[
"audio_timebase"][
"num"].isNull())
338 if (!root[
"audio_timebase"][
"den"].isNull())
int channels
The number of audio channels used in the audio stream.
long long file_size
Size of file (in bytes)
void AppendDebugMethod(string method_name, string arg1_name, float arg1_value, string arg2_name, float arg2_value, string arg3_name, float arg3_value, string arg4_name, float arg4_value, string arg5_name, float arg5_value, string arg6_name, float arg6_value)
Append debug information as JSON.
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...
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.
void Log(string message)
Log message to all subscribers of this logger (if any)
Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) ...
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.
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)
static ZmqLogger * Instance()
Create or get an instance of this logger singleton (invoke the class with this method) ...
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.
int audio_stream_index
The index of the audio stream.
Exception for invalid JSON.
int file_size
Size of file (in bytes)
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.
long int video_length
The number of frames in the video stream.
long int video_length
The number of frames in 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)