diff --git a/include/FFmpegWriter.h b/include/FFmpegWriter.h index dc3a2cf7b..654e72cc0 100644 --- a/include/FFmpegWriter.h +++ b/include/FFmpegWriter.h @@ -287,6 +287,15 @@ namespace openshot { /// @param bit_rate The audio bit rate used during encoding void SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, openshot::ChannelLayout channel_layout, int bit_rate); + /// @brief Set audio export options. + /// + /// Enables the stream and configures a default 2-channel stereo layout. + /// + /// @param codec The codec used to encode the audio for this file + /// @param sample_rate The number of audio samples needed in this file + /// @param bit_rate The audio bit rate used during encoding + void SetAudioOptions(std::string codec, int sample_rate, int bit_rate); + /// @brief Set the cache size /// @param new_size The number of frames to queue before writing to the file void SetCacheSize(int new_size) { cache_size = new_size; }; @@ -303,8 +312,20 @@ namespace openshot { /// @param bit_rate The video bit rate used during encoding 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); + /// @brief Set video export options. + /// + /// Enables the stream and configures non-interlaced video with a 1:1 pixel aspect ratio. + /// + /// @param codec The codec used to encode the images in this video + /// @param fps The number of frames per second + /// @param width The width in pixels of this video + /// @param height The height in pixels of this video + /// @param bit_rate The video bit rate used during encoding + void SetVideoOptions(std::string codec, openshot::Fraction fps, int width, int height, int bit_rate); + /// @brief Set custom options (some codecs accept additional params). This must be called after the /// PrepareStreams() method, otherwise the streams have not been initialized yet. + /// /// @param stream The stream (openshot::StreamType) this option should apply to /// @param name The name of the option you want to set (i.e. qmin, qmax, etc...) /// @param value The new value of this option diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 245bd9bd6..c01a09ed2 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -277,6 +277,14 @@ void FFmpegWriter::SetVideoOptions(bool has_video, std::string codec, Fraction f info.has_video = has_video; } +// Set video export options (overloaded function) +void FFmpegWriter::SetVideoOptions(std::string codec, Fraction fps, int width, int height, int bit_rate) { + // Call full signature with some default parameters + FFmpegWriter::SetVideoOptions(true, codec, fps, width, height, + openshot::Fraction(1, 1), false, true, bit_rate); +} + + // Set audio export options void FFmpegWriter::SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, ChannelLayout channel_layout, int bit_rate) { // Set audio options @@ -312,6 +320,14 @@ void FFmpegWriter::SetAudioOptions(bool has_audio, std::string codec, int sample info.has_audio = has_audio; } + +// Set audio export options (overloaded function) +void FFmpegWriter::SetAudioOptions(std::string codec, int sample_rate, int bit_rate) { + // Call full signature with some default parameters + FFmpegWriter::SetAudioOptions(true, codec, sample_rate, 2, openshot::LAYOUT_STEREO, bit_rate); +} + + // Set custom options (some codecs accept additional params) void FFmpegWriter::SetOption(StreamType stream, std::string name, std::string value) { // Declare codec context