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
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ Style/ArgumentsForwarding:

Style/FloatDivision:
Enabled: false

Style/SafeNavigationChainLength:
Enabled: false
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
== 6.1.2 2024-11-07
Fixes:
* Calculate rotation correctly for media files with multiple side data elements

== 6.1.1 2024-11-04

Fixes:
Expand Down
18 changes: 12 additions & 6 deletions lib/ffmpeg/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ def initialize(metadata, stderr = '')
@coded_height = metadata[:coded_height]
@sample_aspect_ratio = metadata[:sample_aspect_ratio]
@display_aspect_ratio = metadata[:display_aspect_ratio]
@rotation = if metadata[:tags]&.key?(:rotate)
metadata[:tags][:rotate].to_i
elsif metadata[:side_data_list]&.first&.key?(:rotation)
rotation = metadata[:side_data_list].first[:rotation].to_i
rotation.positive? ? 360 - rotation : rotation.abs
end

@rotation =
if metadata.dig(:tags, :rotate)
metadata.dig(:tags, :rotate).to_i
else
metadata[:side_data_list]
&.find { |data| data[:side_data_type] =~ /display matrix/i }
&.dig(:rotation)
&.to_i
&.tap { |value| break value + 180 if value % 180 != 0 }
Comment thread
bajankristof marked this conversation as resolved.
&.abs
end

@color_range = metadata[:color_range]
@color_space = metadata[:pix_fmt] || metadata[:color_space]
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 = '6.1.1'
VERSION = '6.1.2'
end