diff --git a/CHANGELOG b/CHANGELOG index 42ae473..613ca81 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +== 8.1.0 2026-02-04 + +Improvements: +* Added smart audio channel selection to FFMPEG::CommandArgs. + == 8.1.0-beta.5 2025-10-31 Improvements: diff --git a/lib/ffmpeg/command_args.rb b/lib/ffmpeg/command_args.rb index d0b5023..1da8017 100644 --- a/lib/ffmpeg/command_args.rb +++ b/lib/ffmpeg/command_args.rb @@ -109,6 +109,16 @@ def audio_sample_rate(target_value) super(adjusted_audio_sample_rate(target_value)) end + # Sets the audio channels to the minimum of the current audio channels and the target value. + # + # @param target_value [Integer] The target audio channels. + # @return [self] + def audio_channels(target_value) + return self if target_value.nil? + + super(adjusted_audio_channels(target_value)) + end + # Returns the minimum of the current frame rate and the target value. # # @param target_value [Integer, Float] The target frame rate. @@ -155,6 +165,20 @@ def adjusted_audio_sample_rate(target_value) STANDARD_AUDIO_SAMPLE_RATES.min_by { (_1 - media.audio_sample_rate).abs } end + # Returns the minimum of the current audio channels and the target value. + # Returns the target value if the current audio channels is nil or zero/negative. + # If the media audio channels is lower than the target, returns the current audio channels. + # + # @param target_value [Integer] The target audio channels. + # @return [Integer] + def adjusted_audio_channels(target_value) + return target_value if media.audio_channels.nil? + return target_value if media.audio_channels <= 0 + return target_value if media.audio_channels > target_value + + media.audio_channels + end + private def min_bit_rate(*values) diff --git a/lib/ffmpeg/version.rb b/lib/ffmpeg/version.rb index 261c129..70dd7be 100644 --- a/lib/ffmpeg/version.rb +++ b/lib/ffmpeg/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module FFMPEG - VERSION = '8.1.0-beta.5' + VERSION = '8.1.0' end