Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
24 changes: 24 additions & 0 deletions lib/ffmpeg/command_args.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/ffmpeg/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module FFMPEG
VERSION = '8.1.0-beta.5'
VERSION = '8.1.0'
end