diff --git a/app/logical/media_file.rb b/app/logical/media_file.rb index 534f91dbb..5ac19db15 100644 --- a/app/logical/media_file.rb +++ b/app/logical/media_file.rb @@ -60,10 +60,11 @@ class MediaFile # https://www.ftyps.com # isom (common) - MP4 Base Media v1 [IS0 14496-12:2003] # mp42 (common) - MP4 v2 [ISO 14496-14] + # iso5 (rare) - MP4 Base Media v5 (used by Twitter) # 3gp5 (rare) - 3GPP Media (.3GP) Release 5 # avc1 (rare) - MP4 Base w/ AVC ext [ISO 14496-12:2005] # M4V (rare) - Apple iTunes Video (https://en.wikipedia.org/wiki/M4V) - when /\A....ftyp(?:isom|3gp5|mp42|avc1|M4V)/ + when /\A....ftyp(?:isom|iso5|3gp5|mp42|avc1|M4V)/ :mp4 when /\APK\x03\x04/ :zip diff --git a/test/files/test-iso5.mp4 b/test/files/test-iso5.mp4 new file mode 100644 index 000000000..e3805f57e Binary files /dev/null and b/test/files/test-iso5.mp4 differ diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index 0063f8959..c8ea90fa2 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -313,7 +313,8 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest should_upload_successfully("https://pbs.twimg.com/media/DCdZ_FhUIAAYKFN?format=jpg&name=medium") should_upload_successfully("https://pbs.twimg.com/profile_banners/2371694594/1581832507/1500x500") should_upload_successfully("https://twitter.com/zeth_total/status/1355597580814585856") - # XXX should_upload_successfully("https://video.twimg.com/tweet_video/EWHWVrmVcAAp4Vw.mp4") + should_upload_successfully("https://video.twimg.com/tweet_video/FLKI6DWakAQFRkC.mp4") + should_upload_successfully("https://video.twimg.com/tweet_video/EWHWVrmVcAAp4Vw.mp4") should_upload_successfully("https://www.weibo.com/5501756072/J2UNKfbqV") should_upload_successfully("https://wx1.sinaimg.cn/mw690/0060kO5aly1gezsyt5xvhj30ok0sgtc9.jpg") diff --git a/test/unit/media_file_test.rb b/test/unit/media_file_test.rb index c1f4f9866..1f4b78194 100644 --- a/test/unit/media_file_test.rb +++ b/test/unit/media_file_test.rb @@ -97,6 +97,10 @@ class MediaFileTest < ActiveSupport::TestCase assert_equal(:mp4, MediaFile.open("test/files/test-audio.m4v").file_ext) end + should "determine the correct extension for an iso5 mp4 file" do + assert_equal(:mp4, MediaFile.open("test/files/test-iso5.mp4").file_ext) + end + should "determine the correct extension for a ugoira file" do assert_equal(:zip, MediaFile.open("test/files/ugoira.zip").file_ext) end