36 #ifndef OPENSHOT_FFMPEG_WRITER_H
37 #define OPENSHOT_FFMPEG_WRITER_H
151 int64_t write_video_count;
152 int64_t write_audio_count;
154 bool prepare_streams;
160 AVStream *audio_st, *video_st;
161 AVCodecContext *video_codec;
162 AVCodecContext *audio_codec;
163 SwsContext *img_convert_ctx;
164 double audio_pts, video_pts;
166 uint8_t *audio_outbuf;
167 uint8_t *audio_encoder_buffer;
169 int num_of_rescalers;
170 int rescaler_position;
171 vector<SwsContext*> image_rescalers;
173 int audio_outbuf_size;
174 int audio_input_frame_size;
175 int initial_audio_input_frame_size;
176 int audio_input_position;
177 int audio_encoder_buffer_size;
182 int original_sample_rate;
183 int original_channels;
185 std::shared_ptr<Frame> last_frame;
186 deque<std::shared_ptr<Frame> > spooled_audio_frames;
187 deque<std::shared_ptr<Frame> > spooled_video_frames;
189 deque<std::shared_ptr<Frame> > queued_audio_frames;
190 deque<std::shared_ptr<Frame> > queued_video_frames;
192 deque<std::shared_ptr<Frame> > processed_frames;
193 deque<std::shared_ptr<Frame> > deallocate_frames;
195 map<std::shared_ptr<Frame>, AVFrame*> av_frames;
198 void add_avframe(std::shared_ptr<Frame> frame, AVFrame* av_frame);
201 AVStream* add_audio_stream();
204 AVStream* add_video_stream();
207 AVFrame* allocate_avframe(
PixelFormat pix_fmt,
int width,
int height,
int *buffer_size, uint8_t *new_buffer);
210 void auto_detect_format();
213 void close_audio(AVFormatContext *oc, AVStream *st);
216 void close_video(AVFormatContext *oc, AVStream *st);
219 void flush_encoders();
222 void initialize_streams();
227 void InitScalers(
int source_width,
int source_height);
230 void open_audio(AVFormatContext *oc, AVStream *st);
233 void open_video(AVFormatContext *oc, AVStream *st);
236 void process_video_packet(std::shared_ptr<Frame> frame);
239 void write_audio_packets(
bool final);
242 bool write_video_packet(std::shared_ptr<Frame> frame, AVFrame* frame_final);
245 void write_queued_frames();
263 static bool IsValidCodec(
string codec_name);
269 void OutputStreamInfo();
273 void PrepareStreams();
276 void RemoveScalers();
281 void ResampleAudio(
int sample_rate,
int channels);
290 void SetAudioOptions(
bool has_audio,
string codec,
int sample_rate,
int channels,
ChannelLayout channel_layout,
int bit_rate);
306 void SetVideoOptions(
bool has_video,
string codec,
Fraction fps,
int width,
int height,
Fraction pixel_ratio,
bool interlaced,
bool top_field_first,
int bit_rate);
313 void SetOption(
StreamType stream,
string name,
string value);
321 void WriteFrame(std::shared_ptr<Frame> frame);
327 void WriteFrame(
ReaderBase* reader, int64_t start, int64_t length);
A video stream (used to determine which type of stream)
int GetCacheSize()
Get the cache size (number of frames to queue before writing)
An audio stream (used to determine which type of stream)
Header file for ReaderBase class.
Header file for OpenMPUtilities (set some common macros)
This class uses the FFmpeg libraries, to write and encode video files and audio files.
This abstract class is the base class, used by all readers in libopenshot.
Header file for CacheMemory class.
bool IsOpen()
Determine if writer is open or closed.
Header file for all Exception classes.
Header file for WriterBase class.
This abstract class is the base class, used by writers. Writers are types of classes that encode vide...
This class represents a fraction.
Header file for ZeroMQ-based Logger class.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround...
void SetCacheSize(int new_size)
Set the cache size.
Header file for global Settings class.
Header file for FFmpegUtilities.
StreamType
This enumeration designates the type of stream when encoding (video or audio)