Skip to content

Commit

Permalink
Merge pull request #6034 from avalonmediasystem/video_check
Browse files Browse the repository at this point in the history
Convert fall back display aspect ratio to string
  • Loading branch information
masaball authored Sep 16, 2024
2 parents e07abd8 + 48d249a commit fe09a36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit fe09a36

Please sign in to comment.