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

Convert fall back display aspect ratio to string #6034

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/avalon/ffprobe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def display_aspect_ratio
if video? && video_stream[:display_aspect_ratio].present?
video_stream[:display_aspect_ratio]
elsif video?
video_stream[:width].to_f / video_stream[:height].to_f
(video_stream[:width].to_f / video_stream[:height].to_f).to_s
end
end

Expand Down
4 changes: 3 additions & 1 deletion spec/lib/avalon/ffprobe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@
let(:test_file) { video_file }

it 'returns the display aspect ratio' do
expect(subject.display_aspect_ratio).to be_a(String)
expect(subject.display_aspect_ratio).to eq '20:11'
end

context 'file missing display aspect ratio' do
it 'calculates the display aspect ratio' do
subject.instance_variable_set(:@video_stream, subject.video_stream.except!(:display_aspect_ratio))
expect(subject.display_aspect_ratio).to eq(200.to_f / 110.to_f)
expect(subject.display_aspect_ratio).to be_a(String)
expect(subject.display_aspect_ratio).to eq((200.to_f / 110.to_f).to_s)
end
end
end
Expand Down