Skip to content

Commit 7867cf0

Browse files
committed
Reorder arguments in setVideoOptions overload
- The new ordering (with the frame rate AFTER width and height) doesn't match the other signature, but it *is* consistent with the Timeline constructor, and it just feels more natural - Added overloaded-function notes to doxygen strings in FFmpegWriter.h - Also added a warning about the argument order mismatch above
1 parent bad0a34 commit 7867cf0

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

include/FFmpegWriter.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ namespace openshot {
285285
/// @param channels The number of audio channels needed in this file
286286
/// @param channel_layout The 'layout' of audio channels (i.e. mono, stereo, surround, etc...)
287287
/// @param bit_rate The audio bit rate used during encoding
288+
///
289+
/// \note This is an overloaded function.
288290
void SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, openshot::ChannelLayout channel_layout, int bit_rate);
289291

290292
/// @brief Set audio export options.
@@ -294,6 +296,8 @@ namespace openshot {
294296
/// @param codec The codec used to encode the audio for this file
295297
/// @param sample_rate The number of audio samples needed in this file
296298
/// @param bit_rate The audio bit rate used during encoding
299+
///
300+
/// \note This is an overloaded function.
297301
void SetAudioOptions(std::string codec, int sample_rate, int bit_rate);
298302

299303
/// @brief Set the cache size
@@ -310,18 +314,23 @@ namespace openshot {
310314
/// @param interlaced Does this video need to be interlaced?
311315
/// @param top_field_first Which frame should be used as the top field?
312316
/// @param bit_rate The video bit rate used during encoding
317+
///
318+
/// \note This is an overloaded function.
313319
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);
314320

315321
/// @brief Set video export options.
316322
///
317323
/// Enables the stream and configures non-interlaced video with a 1:1 pixel aspect ratio.
318324
///
319325
/// @param codec The codec used to encode the images in this video
320-
/// @param fps The number of frames per second
321326
/// @param width The width in pixels of this video
322327
/// @param height The height in pixels of this video
328+
/// @param fps The number of frames per second
323329
/// @param bit_rate The video bit rate used during encoding
324-
void SetVideoOptions(std::string codec, openshot::Fraction fps, int width, int height, int bit_rate);
330+
///
331+
/// \note This is an overloaded function.
332+
/// \warning Observe the argument order, which is consistent with the openshot::Timeline constructor, but differs from the other signature.
333+
void SetVideoOptions(std::string codec, int width, int height, openshot::Fraction fps, int bit_rate);
325334

326335
/// @brief Set custom options (some codecs accept additional params). This must be called after the
327336
/// PrepareStreams() method, otherwise the streams have not been initialized yet.
@@ -337,12 +346,16 @@ namespace openshot {
337346

338347
/// @brief Add a frame to the stack waiting to be encoded.
339348
/// @param frame The openshot::Frame object to write to this image
349+
///
350+
/// \note This is an overloaded function.
340351
void WriteFrame(std::shared_ptr<openshot::Frame> frame);
341352

342353
/// @brief Write a block of frames from a reader
343354
/// @param reader A openshot::ReaderBase object which will provide frames to be written
344355
/// @param start The starting frame number of the reader
345356
/// @param length The number of frames to write
357+
///
358+
/// \note This is an overloaded function.
346359
void WriteFrame(openshot::ReaderBase *reader, int64_t start, int64_t length);
347360

348361
/// @brief Write the file trailer (after all frames are written). This is called automatically

src/FFmpegWriter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, std::string codec, Fraction f
278278
}
279279

280280
// Set video export options (overloaded function)
281-
void FFmpegWriter::SetVideoOptions(std::string codec, Fraction fps, int width, int height, int bit_rate) {
281+
void FFmpegWriter::SetVideoOptions(std::string codec, int width, int height, Fraction fps, int bit_rate) {
282282
// Call full signature with some default parameters
283283
FFmpegWriter::SetVideoOptions(true, codec, fps, width, height,
284284
openshot::Fraction(1, 1), false, true, bit_rate);
@@ -324,7 +324,8 @@ void FFmpegWriter::SetAudioOptions(bool has_audio, std::string codec, int sample
324324
// Set audio export options (overloaded function)
325325
void FFmpegWriter::SetAudioOptions(std::string codec, int sample_rate, int bit_rate) {
326326
// Call full signature with some default parameters
327-
FFmpegWriter::SetAudioOptions(true, codec, sample_rate, 2, openshot::LAYOUT_STEREO, bit_rate);
327+
FFmpegWriter::SetAudioOptions(true, codec, sample_rate, 2,
328+
openshot::LAYOUT_STEREO, bit_rate);
328329
}
329330

330331

tests/FFmpegWriter_Tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ TEST(Options_Overloads)
9797

9898
// Set options
9999
w.SetAudioOptions("aac", 48000, 192000);
100-
w.SetVideoOptions("libx264", Fraction(30,1), 1280, 720, 5000000);
100+
w.SetVideoOptions("libx264", 1280, 720, Fraction(30,1), 5000000);
101101

102102
// Open writer
103103
w.Open();

0 commit comments

Comments
 (0)