36 #ifndef OPENSHOT_FFMPEG_WRITER_H
37 #define OPENSHOT_FFMPEG_WRITER_H
149 int64 write_video_count;
150 int64 write_audio_count;
152 bool prepare_streams;
158 AVStream *audio_st, *video_st;
159 AVCodecContext *video_codec;
160 AVCodecContext *audio_codec;
161 SwsContext *img_convert_ctx;
162 double audio_pts, video_pts;
164 uint8_t *audio_outbuf;
165 uint8_t *audio_encoder_buffer;
167 int num_of_rescalers;
168 int rescaler_position;
169 vector<SwsContext*> image_rescalers;
171 int audio_outbuf_size;
172 int audio_input_frame_size;
173 int initial_audio_input_frame_size;
174 int audio_input_position;
175 int audio_encoder_buffer_size;
176 AVAudioResampleContext *avr;
177 AVAudioResampleContext *avr_planar;
180 int original_sample_rate;
181 int original_channels;
183 tr1::shared_ptr<Frame> last_frame;
184 deque<tr1::shared_ptr<Frame> > spooled_audio_frames;
185 deque<tr1::shared_ptr<Frame> > spooled_video_frames;
187 deque<tr1::shared_ptr<Frame> > queued_audio_frames;
188 deque<tr1::shared_ptr<Frame> > queued_video_frames;
190 deque<tr1::shared_ptr<Frame> > processed_frames;
191 deque<tr1::shared_ptr<Frame> > deallocate_frames;
193 map<tr1::shared_ptr<Frame>, AVFrame*> av_frames;
196 void add_avframe(tr1::shared_ptr<Frame> frame, AVFrame* av_frame);
199 AVStream* add_audio_stream();
202 AVStream* add_video_stream();
205 AVFrame* allocate_avframe(
PixelFormat pix_fmt,
int width,
int height,
int *buffer_size, uint8_t *new_buffer);
208 void auto_detect_format();
211 void close_audio(AVFormatContext *oc, AVStream *st);
214 void close_video(AVFormatContext *oc, AVStream *st);
217 void flush_encoders();
220 void initialize_streams();
225 void InitScalers(
int source_width,
int source_height);
228 void open_audio(AVFormatContext *oc, AVStream *st);
231 void open_video(AVFormatContext *oc, AVStream *st);
234 void process_video_packet(tr1::shared_ptr<Frame> frame);
237 void write_audio_packets(
bool final);
240 bool write_video_packet(tr1::shared_ptr<Frame> frame, AVFrame* frame_final);
264 void OutputStreamInfo();
268 void PrepareStreams();
271 void RemoveScalers();
276 void ResampleAudio(
int sample_rate,
int channels);
285 void SetAudioOptions(
bool has_audio,
string codec,
int sample_rate,
int channels,
ChannelLayout channel_layout,
int bit_rate)
286 throw(InvalidFile, InvalidFormat, InvalidCodec, InvalidOptions, OutOfMemory, InvalidChannels);
290 void SetCacheSize(
int new_size) { cache_size = new_size; };
302 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)
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.
Exception when an invalid # of audio channels are detected.
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.
bool IsOpen()
Determine if writer is open or closed.
Exception when encoding audio packet.
Exception when invalid sample rate is detected during encoding.
Header file for all Exception classes.
Exception when no valid codec is found for a file.
Exception when memory could not be allocated.
Exception when invalid encoding options are used.
Exception when no streams are found in the file.
Exception for files that can not be found or opened.
Header file for WriterBase class.
This abstract class is the base class, used by writers. Writers are types of classes that encode vide...
Header file for Cache class.
This class represents a fraction.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround...
Exception when a writer is closed, and a frame is requested.
Header file for FFmpegUtilities.
StreamType
This enumeration designates the type of stream when encoding (video or audio)