Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimensions: support for rotation inside side_data_list #229

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions lib/ffmpeg/movie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def initialize(path)

@rotation = if video_stream.key?(:tags) and video_stream[:tags].key?(:rotate)
video_stream[:tags][:rotate].to_i
elsif video_stream.key?(:side_data_list)
rotation_data = video_stream[:side_data_list].find { |data| data.key?(:rotation) }
rotation_data ? rotation_data[:rotation].to_i : nil
else
nil
end
Expand Down Expand Up @@ -156,11 +159,17 @@ def local?
end

def width
rotation.nil? || rotation == 180 ? @width : @height;
return @width if rotation.nil?

normalized_rotation = rotation % 360
normalized_rotation == 180 || normalized_rotation == 0 ? @width : @height
end

def height
rotation.nil? || rotation == 180 ? @height : @width;
return @height if rotation.nil?

normalized_rotation = rotation % 360
normalized_rotation == 180 || normalized_rotation == 0 ? @height : @width
end

def resolution
Expand Down