Skip to content

Commit a3404b8

Browse files
authored
Merge pull request #7 from instructure/fix/rotation
fix: rotation is not calculated for media with multiple side data elements
2 parents 424e251 + 87113bb commit a3404b8

4 files changed

Lines changed: 20 additions & 7 deletions

File tree

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ Style/ArgumentsForwarding:
3737

3838
Style/FloatDivision:
3939
Enabled: false
40+
41+
Style/SafeNavigationChainLength:
42+
Enabled: false

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
== 6.1.2 2024-11-07
2+
Fixes:
3+
* Calculate rotation correctly for media files with multiple side data elements
4+
15
== 6.1.1 2024-11-04
26

37
Fixes:

lib/ffmpeg/stream.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ def initialize(metadata, stderr = '')
4444
@coded_height = metadata[:coded_height]
4545
@sample_aspect_ratio = metadata[:sample_aspect_ratio]
4646
@display_aspect_ratio = metadata[:display_aspect_ratio]
47-
@rotation = if metadata[:tags]&.key?(:rotate)
48-
metadata[:tags][:rotate].to_i
49-
elsif metadata[:side_data_list]&.first&.key?(:rotation)
50-
rotation = metadata[:side_data_list].first[:rotation].to_i
51-
rotation.positive? ? 360 - rotation : rotation.abs
52-
end
47+
48+
@rotation =
49+
if metadata.dig(:tags, :rotate)
50+
metadata.dig(:tags, :rotate).to_i
51+
else
52+
metadata[:side_data_list]
53+
&.find { |data| data[:side_data_type] =~ /display matrix/i }
54+
&.dig(:rotation)
55+
&.to_i
56+
&.tap { |value| break value + 180 if value % 180 != 0 }
57+
&.abs
58+
end
5359

5460
@color_range = metadata[:color_range]
5561
@color_space = metadata[:pix_fmt] || metadata[:color_space]

lib/ffmpeg/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module FFMPEG
4-
VERSION = '6.1.1'
4+
VERSION = '6.1.2'
55
end

0 commit comments

Comments
 (0)