aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/analyzer/video_analyzer_test.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-01-19 10:47:18 -0500
committerGeorge Claghorn <george@basecamp.com>2018-01-19 10:47:34 -0500
commit2450fc24e30121863403517b44dfdfa7cb25e33a (patch)
tree79219c87c1c317d0a6c99071959726f88fb65e1f /activestorage/test/analyzer/video_analyzer_test.rb
parentacbcef6094d61eb8c4820295620d170743a4bd71 (diff)
downloadrails-2450fc24e30121863403517b44dfdfa7cb25e33a.tar.gz
rails-2450fc24e30121863403517b44dfdfa7cb25e33a.tar.bz2
rails-2450fc24e30121863403517b44dfdfa7cb25e33a.zip
Preserve display aspect ratio for videos with rectangular samples
Diffstat (limited to 'activestorage/test/analyzer/video_analyzer_test.rb')
-rw-r--r--activestorage/test/analyzer/video_analyzer_test.rb22
1 files changed, 18 insertions, 4 deletions
diff --git a/activestorage/test/analyzer/video_analyzer_test.rb b/activestorage/test/analyzer/video_analyzer_test.rb
index 7fc1cfce06..03fbd72735 100644
--- a/activestorage/test/analyzer/video_analyzer_test.rb
+++ b/activestorage/test/analyzer/video_analyzer_test.rb
@@ -8,28 +8,42 @@ require "active_storage/analyzer/video_analyzer"
class ActiveStorage::Analyzer::VideoAnalyzerTest < ActiveSupport::TestCase
test "analyzing a video" do
blob = create_file_blob(filename: "video.mp4", content_type: "video/mp4")
- metadata = blob.tap(&:analyze).metadata
+ metadata = extract_metadata_from(blob)
assert_equal 640, metadata[:width]
assert_equal 480, metadata[:height]
- assert_equal [4, 3], metadata[:aspect_ratio]
+ assert_equal [4, 3], metadata[:display_aspect_ratio]
assert_equal 5.166648, metadata[:duration]
assert_not_includes metadata, :angle
end
test "analyzing a rotated video" do
blob = create_file_blob(filename: "rotated_video.mp4", content_type: "video/mp4")
- metadata = blob.tap(&:analyze).metadata
+ metadata = extract_metadata_from(blob)
assert_equal 480, metadata[:width]
assert_equal 640, metadata[:height]
- assert_equal [4, 3], metadata[:aspect_ratio]
+ assert_equal [4, 3], metadata[:display_aspect_ratio]
assert_equal 5.227975, metadata[:duration]
assert_equal 90, metadata[:angle]
end
+ test "analyzing a video with rectangular samples" do
+ blob = create_file_blob(filename: "video_with_rectangular_samples.mp4", content_type: "video/mp4")
+ metadata = extract_metadata_from(blob)
+
+ assert_equal 1280, metadata[:width]
+ assert_equal 720, metadata[:height]
+ assert_equal [16, 9], metadata[:display_aspect_ratio]
+ end
+
test "analyzing a video without a video stream" do
blob = create_file_blob(filename: "video_without_video_stream.mp4", content_type: "video/mp4")
assert_equal({ "analyzed" => true, "identified" => true }, blob.tap(&:analyze).metadata)
end
+
+ private
+ def extract_metadata_from(blob)
+ blob.tap(&:analyze).metadata
+ end
end