|
OpenShot Library | libopenshot
0.5.0
|
Go to the documentation of this file.
16 #ifndef OPENSHOT_FFMPEG_WRITER_H
17 #define OPENSHOT_FFMPEG_WRITER_H
121 int64_t video_timestamp;
122 int64_t audio_timestamp;
124 bool prepare_streams;
130 AVStream *audio_st, *video_st;
131 AVCodecContext *video_codec_ctx;
132 AVCodecContext *audio_codec_ctx;
133 SwsContext *img_convert_ctx;
135 uint8_t *audio_outbuf;
136 uint8_t *audio_encoder_buffer;
138 AVFrame *persistent_src_frame =
nullptr;
139 AVFrame *persistent_dst_frame =
nullptr;
140 uint8_t *persistent_dst_buffer =
nullptr;
141 int persistent_dst_size = 0;
143 int audio_outbuf_size;
144 int audio_input_frame_size;
145 int initial_audio_input_frame_size;
146 int audio_input_position;
147 int audio_encoder_buffer_size;
152 int original_sample_rate;
153 int original_channels;
155 std::shared_ptr<openshot::Frame> last_frame;
156 std::map<std::shared_ptr<openshot::Frame>, AVFrame *> av_frames;
159 void add_avframe(std::shared_ptr<openshot::Frame> frame, AVFrame *av_frame);
162 AVStream *add_audio_stream();
165 AVStream *add_video_stream();
168 AVFrame *allocate_avframe(
PixelFormat pix_fmt,
int width,
int height,
int *buffer_size, uint8_t *new_buffer);
171 void auto_detect_format();
174 void close_audio(AVFormatContext *oc, AVStream *st);
177 void close_video(AVFormatContext *oc, AVStream *st);
180 void flush_encoders();
183 void initialize_streams();
186 void open_audio(AVFormatContext *oc, AVStream *st);
189 void open_video(AVFormatContext *oc, AVStream *st);
192 void process_video_packet(std::shared_ptr<openshot::Frame> frame);
195 void write_audio_packets(
bool is_final, std::shared_ptr<openshot::Frame> frame);
198 bool write_video_packet(std::shared_ptr<openshot::Frame> frame, AVFrame *frame_final);
201 void write_frame(std::shared_ptr<Frame> frame);
301 void WriteFrame(std::shared_ptr<openshot::Frame> frame);
320 void AddSphericalMetadata(
const std::string& projection=
"equirectangular",
float yaw_deg=0.0f,
float pitch_deg=0.0f,
float roll_deg=0.0f);
@ 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.
This class represents a fraction.
FFmpegWriter(const std::string &path)
Constructor for FFmpegWriter. Throws an exception on failure to open path.
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.
void AddSphericalMetadata(const std::string &projection="equirectangular", float yaw_deg=0.0f, float pitch_deg=0.0f, float roll_deg=0.0f)
Add spherical (360°) video metadata to the video stream.
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...
@ 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.
static bool IsValidCodec(std::string codec_name)
Determine if codec name is valid.
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 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...