OpenShot Library | libopenshot
0.2.5
|
Go to the documentation of this file.
39 #ifndef OPENSHOT_FFMPEG_WRITER_H
40 #define OPENSHOT_FFMPEG_WRITER_H
157 int64_t write_video_count;
158 int64_t write_audio_count;
160 bool prepare_streams;
166 AVStream *audio_st, *video_st;
167 AVCodecContext *video_codec;
168 AVCodecContext *audio_codec;
169 SwsContext *img_convert_ctx;
170 double audio_pts, video_pts;
172 uint8_t *audio_outbuf;
173 uint8_t *audio_encoder_buffer;
175 int num_of_rescalers;
176 int rescaler_position;
177 std::vector<SwsContext *> image_rescalers;
179 int audio_outbuf_size;
180 int audio_input_frame_size;
181 int initial_audio_input_frame_size;
182 int audio_input_position;
183 int audio_encoder_buffer_size;
188 int original_sample_rate;
189 int original_channels;
191 std::shared_ptr<openshot::Frame> last_frame;
192 std::deque<std::shared_ptr<openshot::Frame> > spooled_audio_frames;
193 std::deque<std::shared_ptr<openshot::Frame> > spooled_video_frames;
195 std::deque<std::shared_ptr<openshot::Frame> > queued_audio_frames;
196 std::deque<std::shared_ptr<openshot::Frame> > queued_video_frames;
198 std::deque<std::shared_ptr<openshot::Frame> > processed_frames;
199 std::deque<std::shared_ptr<openshot::Frame> > deallocate_frames;
201 std::map<std::shared_ptr<openshot::Frame>, AVFrame *> av_frames;
204 void add_avframe(std::shared_ptr<openshot::Frame> frame, AVFrame *av_frame);
207 AVStream *add_audio_stream();
210 AVStream *add_video_stream();
213 AVFrame *allocate_avframe(
PixelFormat pix_fmt,
int width,
int height,
int *buffer_size, uint8_t *new_buffer);
216 void auto_detect_format();
219 void close_audio(AVFormatContext *oc, AVStream *st);
222 void close_video(AVFormatContext *oc, AVStream *st);
225 void flush_encoders();
228 void initialize_streams();
233 void InitScalers(
int source_width,
int source_height);
236 void open_audio(AVFormatContext *oc, AVStream *st);
239 void open_video(AVFormatContext *oc, AVStream *st);
242 void process_video_packet(std::shared_ptr<openshot::Frame> frame);
245 void write_audio_packets(
bool is_final);
248 bool write_video_packet(std::shared_ptr<openshot::Frame> frame, AVFrame *frame_final);
251 void write_queued_frames();
359 void WriteFrame(std::shared_ptr<openshot::Frame> frame);
Header file for global Settings class.
@ AUDIO_STREAM
An audio stream (used to determine which type of stream)
Header file for FFmpegUtilities.
Header file for WriterBase class.
void ResampleAudio(int sample_rate, int channels)
Set audio resample options.
void OutputStreamInfo()
Output the ffmpeg info about this format, streams, and codecs (i.e. dump format)
This namespace is the default namespace for all code in the openshot library.
FFmpegWriter(std::string path)
Constructor for FFmpegWriter. Throws one of the following exceptions.
This class represents a fraction.
void SetVideoOptions(bool has_video, std::string codec, openshot::Fraction fps, int width, int height, openshot::Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate)
Set video export options.
This class uses the FFmpeg libraries, to write and encode video files and audio files.
bool IsOpen()
Determine if writer is open or closed.
Header file for ZeroMQ-based Logger class.
void SetOption(openshot::StreamType stream, std::string name, std::string value)
Set custom options (some codecs accept additional params). This must be called after the PrepareStrea...
int GetCacheSize()
Get the cache size (number of frames to queue before writing)
Header file for CacheMemory class.
@ VIDEO_STREAM
A video stream (used to determine which type of stream)
void WriteFrame(std::shared_ptr< openshot::Frame > frame)
Add a frame to the stack waiting to be encoded.
Header file for ReaderBase class.
void Close()
Close the writer.
void SetCacheSize(int new_size)
Set the cache size.
static bool IsValidCodec(std::string codec_name)
Determine if codec name is valid.
Header file for OpenMPUtilities (set some common macros)
void WriteTrailer()
Write the file trailer (after all frames are written). This is called automatically by the Close() me...
This abstract class is the base class, used by all readers in libopenshot.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround,...
void SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, openshot::ChannelLayout channel_layout, int bit_rate)
Set audio export options.
StreamType
This enumeration designates the type of stream when encoding (video or audio)
void PrepareStreams()
Prepare & initialize streams and open codecs. This method is called automatically by the Open() metho...
void RemoveScalers()
Remove & deallocate all software scalers.
Header file for all Exception classes.
void WriteHeader()
Write the file header (after the options are set). This method is called automatically by the Open() ...
This abstract class is the base class, used by writers. Writers are types of classes that encode vide...