OpenShot Library | libopenshot  0.3.0
WriterBase.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_WRITER_BASE_H
14 #define OPENSHOT_WRITER_BASE_H
15 
16 #include <iostream>
17 
18 #include "ChannelLayouts.h"
19 #include "Fraction.h"
20 #include "Json.h"
21 
22 namespace openshot
23 {
24  class ReaderBase;
25  class Frame;
32  struct WriterInfo
33  {
34  bool has_video;
35  bool has_audio;
37  float duration;
38  int64_t file_size;
39  int height;
40  int width;
46  std::string vcodec;
47  int64_t video_length;
52  std::string acodec;
55  int channels;
59  std::map<std::string, std::string> metadata;
60  };
61 
69  class WriterBase
70  {
71  public:
73  WriterBase();
74 
77 
80  void CopyReaderInfo(openshot::ReaderBase* reader);
81 
83  virtual bool IsOpen() = 0;
84 
86  virtual void WriteFrame(std::shared_ptr<openshot::Frame> frame) = 0;
87 
89  virtual void WriteFrame(openshot::ReaderBase* reader, int64_t start, int64_t length) = 0;
90 
91  // Get and Set JSON methods
92  std::string Json() const;
93  Json::Value JsonValue() const;
94  void SetJson(const std::string value);
95  void SetJsonValue(const Json::Value root);
96 
98  void DisplayInfo(std::ostream* out=&std::cout);
99 
101  virtual void Open() = 0;
102 
103  virtual ~WriterBase() = default;
104  };
105 
106 }
107 
108 #endif
int channels
The number of audio channels used in the audio stream.
Definition: WriterBase.h:55
Header file for Fraction class.
WriterInfo info
Information about the current media file.
Definition: WriterBase.h:76
int video_bit_rate
The bit rate of the video stream (in bytes)
Definition: WriterBase.h:43
int64_t video_length
The number of frames in the video stream.
Definition: WriterBase.h:47
openshot::Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) ...
Definition: WriterBase.h:45
This struct contains info about encoding a media file, such as height, width, frames per second...
Definition: WriterBase.h:32
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:75
int width
The width of the video (in pixels)
Definition: WriterBase.h:40
int audio_bit_rate
The bit rate of the audio stream (in bytes)
Definition: WriterBase.h:53
openshot::Fraction video_timebase
The video timebase determines how long each frame stays on the screen.
Definition: WriterBase.h:49
std::string acodec
The name of the audio codec used to encode / decode the video stream.
Definition: WriterBase.h:52
openshot::ChannelLayout channel_layout
The channel layout (mono, stereo, 5 point surround, etc...)
Definition: WriterBase.h:56
openshot::Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) ...
Definition: WriterBase.h:44
int64_t file_size
Size of file (in bytes)
Definition: WriterBase.h:38
int video_stream_index
The index of the video stream.
Definition: WriterBase.h:48
float duration
Length of time (in seconds)
Definition: WriterBase.h:37
bool top_field_first
Which interlaced field should be displayed first.
Definition: WriterBase.h:51
This abstract class is the base class, used by writers. Writers are types of classes that encode vide...
Definition: WriterBase.h:69
Header file for JSON class.
This class represents a fraction.
Definition: Fraction.h:30
openshot::Fraction audio_timebase
The audio timebase determines how long each audio packet should be played.
Definition: WriterBase.h:58
int pixel_format
The pixel format (i.e. YUV420P, RGB24, etc...)
Definition: WriterBase.h:41
Header file for ChannelLayout class.
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.
Definition: WriterBase.h:50
int sample_rate
The number of audio samples per second (44100 is a common sample rate)
Definition: WriterBase.h:54
bool has_video
Determines if this file has a video stream.
Definition: WriterBase.h:34
std::map< std::string, std::string > metadata
An optional map/dictionary of video & audio metadata.
Definition: WriterBase.h:59
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
int audio_stream_index
The index of the audio stream.
Definition: WriterBase.h:57
bool has_audio
Determines if this file has an audio stream.
Definition: WriterBase.h:35
std::string vcodec
The name of the video codec used to encode / decode the video stream.
Definition: WriterBase.h:46
int height
The height of the video (in pixels)
Definition: WriterBase.h:39
openshot::Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
Definition: WriterBase.h:42
bool has_single_image
Determines if this file only contains a single image.
Definition: WriterBase.h:36