Skip to content

Commit

Permalink
fix: rotation is not calculated for media with multiple side data ele…
Browse files Browse the repository at this point in the history
…ments

Refs: ARC-10124
  • Loading branch information
bajankristof committed Nov 7, 2024
1 parent 424e251 commit 1eb2e6c
Showing 1 changed file with 12 additions and 6 deletions.
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 }
&.abs
end

@color_range = metadata[:color_range]
@color_space = metadata[:pix_fmt] || metadata[:color_space]
Expand Down

0 comments on commit 1eb2e6c

Please sign in to comment.