From 1eb2e6cc8d424e5108a16c37ebf147172e43aea6 Mon Sep 17 00:00:00 2001 From: bajankristof Date: Thu, 7 Nov 2024 11:21:09 +0100 Subject: [PATCH 1/3] fix: rotation is not calculated for media with multiple side data elements Refs: ARC-10124 --- lib/ffmpeg/stream.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/ffmpeg/stream.rb b/lib/ffmpeg/stream.rb index 96424f1..49965d9 100644 --- a/lib/ffmpeg/stream.rb +++ b/lib/ffmpeg/stream.rb @@ -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] From 77c4ff059c6d9cc5e879dae3552fd999663a8df9 Mon Sep 17 00:00:00 2001 From: bajankristof Date: Thu, 7 Nov 2024 11:32:24 +0100 Subject: [PATCH 2/3] chore: update version to 6.1.2 and document changes --- CHANGELOG | 4 ++++ lib/ffmpeg/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 524f211..444befc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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: diff --git a/lib/ffmpeg/version.rb b/lib/ffmpeg/version.rb index 1d2d847..a91a498 100644 --- a/lib/ffmpeg/version.rb +++ b/lib/ffmpeg/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module FFMPEG - VERSION = '6.1.1' + VERSION = '6.1.2' end From 87113bb8c244a132a759f191cf100e677d8055c6 Mon Sep 17 00:00:00 2001 From: bajankristof Date: Thu, 7 Nov 2024 11:47:43 +0100 Subject: [PATCH 3/3] style: disable safe navigation chain length checks --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 39b073f..c593b11 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -37,3 +37,6 @@ Style/ArgumentsForwarding: Style/FloatDivision: Enabled: false + +Style/SafeNavigationChainLength: + Enabled: false