From 420ed155babd2a5f40307ab40f1e7e815bb91f40 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 21 Nov 2024 11:58:04 +0100 Subject: [PATCH] Fix wrong video dimensions for some rotated videos (#33008) --- app/lib/video_metadata_extractor.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/lib/video_metadata_extractor.rb b/app/lib/video_metadata_extractor.rb index 2155766251e..fda64051218 100644 --- a/app/lib/video_metadata_extractor.rb +++ b/app/lib/video_metadata_extractor.rb @@ -46,6 +46,9 @@ class VideoMetadataExtractor # For some video streams the frame_rate reported by `ffprobe` will be 0/0, but for these streams we # should use `r_frame_rate` instead. Video screencast generated by Gnome Screencast have this issue. @frame_rate ||= @r_frame_rate + # If the video has not been re-encoded by ffmpeg, it may contain rotation information, + # and we need to simulate applying it to the dimensions + @width, @height = @height, @width if video_stream[:side_data_list]&.any? { |x| x[:rotation].abs == 90 } end if (audio_stream = audio_streams.first)