104 std::cout << std::fixed << std::setprecision(2) << std::boolalpha;
105 std::cout <<
"----------------------------" << std::endl;
106 std::cout <<
"----- File Information -----" << std::endl;
107 std::cout <<
"----------------------------" << std::endl;
108 std::cout <<
"--> Has Video: " <<
info.
has_video << std::endl;
109 std::cout <<
"--> Has Audio: " <<
info.
has_audio << std::endl;
111 std::cout <<
"--> Duration: " <<
info.
duration <<
" Seconds" << std::endl;
112 std::cout <<
"--> File Size: " << double(
info.
file_size) / 1024 / 1024 <<
" MB" << std::endl;
113 std::cout <<
"----------------------------" << std::endl;
114 std::cout <<
"----- Video Attributes -----" << std::endl;
115 std::cout <<
"----------------------------" << std::endl;
116 std::cout <<
"--> Width: " <<
info.
width << std::endl;
117 std::cout <<
"--> Height: " <<
info.
height << std::endl;
120 std::cout <<
"--> Video Bit Rate: " <<
info.
video_bit_rate/1000 <<
" kb/s" << std::endl;
123 std::cout <<
"--> Video Codec: " <<
info.
vcodec << std::endl;
124 std::cout <<
"--> Video Length: " <<
info.
video_length <<
" Frames" << std::endl;
129 std::cout <<
"----------------------------" << std::endl;
130 std::cout <<
"----- Audio Attributes -----" << std::endl;
131 std::cout <<
"----------------------------" << std::endl;
132 std::cout <<
"--> Audio Codec: " <<
info.
acodec << std::endl;
133 std::cout <<
"--> Audio Bit Rate: " <<
info.
audio_bit_rate/1000 <<
" kb/s" << std::endl;
134 std::cout <<
"--> Sample Rate: " <<
info.
sample_rate <<
" Hz" << std::endl;
135 std::cout <<
"--> # of Channels: " <<
info.
channels << std::endl;
139 std::cout <<
"----------------------------" << std::endl;
158 std::stringstream filesize_stream;
160 root[
"file_size"] = filesize_stream.str();
164 root[
"fps"] = Json::Value(Json::objectValue);
168 root[
"pixel_ratio"] = Json::Value(Json::objectValue);
171 root[
"display_ratio"] = Json::Value(Json::objectValue);
175 std::stringstream video_length_stream;
177 root[
"video_length"] = video_length_stream.str();
179 root[
"video_timebase"] = Json::Value(Json::objectValue);
190 root[
"audio_timebase"] = Json::Value(Json::objectValue);
208 catch (
const std::exception& e)
211 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
219 if (!root[
"has_video"].isNull())
221 if (!root[
"has_audio"].isNull())
223 if (!root[
"has_single_image"].isNull())
225 if (!root[
"duration"].isNull())
227 if (!root[
"file_size"].isNull())
229 if (!root[
"height"].isNull())
231 if (!root[
"width"].isNull())
233 if (!root[
"pixel_format"].isNull())
235 if (!root[
"fps"].isNull() && root[
"fps"].isObject()) {
236 if (!root[
"fps"][
"num"].isNull())
238 if (!root[
"fps"][
"den"].isNull())
241 if (!root[
"video_bit_rate"].isNull())
243 if (!root[
"pixel_ratio"].isNull() && root[
"pixel_ratio"].isObject()) {
244 if (!root[
"pixel_ratio"][
"num"].isNull())
246 if (!root[
"pixel_ratio"][
"den"].isNull())
249 if (!root[
"display_ratio"].isNull() && root[
"display_ratio"].isObject()) {
250 if (!root[
"display_ratio"][
"num"].isNull())
252 if (!root[
"display_ratio"][
"den"].isNull())
255 if (!root[
"vcodec"].isNull())
257 if (!root[
"video_length"].isNull())
259 if (!root[
"video_stream_index"].isNull())
261 if (!root[
"video_timebase"].isNull() && root[
"video_timebase"].isObject()) {
262 if (!root[
"video_timebase"][
"num"].isNull())
264 if (!root[
"video_timebase"][
"den"].isNull())
267 if (!root[
"interlaced_frame"].isNull())
269 if (!root[
"top_field_first"].isNull())
271 if (!root[
"acodec"].isNull())
274 if (!root[
"audio_bit_rate"].isNull())
276 if (!root[
"sample_rate"].isNull())
278 if (!root[
"channels"].isNull())
280 if (!root[
"channel_layout"].isNull())
282 if (!root[
"audio_stream_index"].isNull())
284 if (!root[
"audio_timebase"].isNull() && root[
"audio_timebase"].isObject()) {
285 if (!root[
"audio_timebase"][
"num"].isNull())
287 if (!root[
"audio_timebase"][
"den"].isNull())
Header file for all Exception classes.
Header file for WriterBase class.
This class represents a fraction.
int num
Numerator for the fraction.
double ToDouble() const
Return this fraction as a double (i.e. 1/2 = 0.5)
int den
Denominator for the fraction.
Exception for invalid JSON.
This abstract class is the base class, used by all readers in libopenshot.
openshot::ReaderInfo info
Information about the current media file.
void CopyReaderInfo(openshot::ReaderBase *reader)
This method copy's the info struct of a reader, and sets the writer with the same info.
std::string Json() const
Generate JSON string of this object.
void DisplayInfo()
Display file information in the standard output stream (stdout)
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Json::Value JsonValue() const
Generate Json::Value for this object.
WriterInfo info
Information about the current media file.
void SetJson(const std::string value)
Load JSON string into this object.
WriterBase()
Constructor for WriterBase class, many things are initialized here.
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,...
const Json::Value stringToJson(const std::string value)
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::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)
int height
The height of the video (in pixels)
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_audio
Determines if this file has an audio stream.
int64_t video_length
The number of frames in the video stream.
int pixel_format
The pixel format (i.e. YUV420P, RGB24, etc...)
bool top_field_first
Which interlaced field should be displayed first.
float duration
Length of time (in seconds)
int channels
The number of audio channels used in the audio stream.
std::string vcodec
The name of the video codec used to encode / decode the video stream.
bool has_video
Determines if this file has a video stream.
int audio_stream_index
The index of the audio stream.
openshot::Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
std::string acodec
The name of the audio codec used to encode / decode the video stream.
openshot::Fraction audio_timebase
The audio timebase determines how long each audio packet should be played.
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.
openshot::ChannelLayout channel_layout
The channel layout (mono, stereo, 5 point surround, etc...)
openshot::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 pixels)
openshot::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.
int sample_rate
The number of audio samples per second (44100 is a common sample rate)
bool interlaced_frame
Are the contents of this frame interlaced.
int64_t file_size
Size of file (in bytes)