MarkTraceur has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/364256 )

Change subject: Add (hacky) check for webm audio files
......................................................................

Add (hacky) check for webm audio files

If there is no video track in a webm file, it's supposed to be audio/webm,
but since we assume every webm file is video/webm, that's never worked.
This should slightly improve searching for audio files.

Bug: T156135
Change-Id: Iac749233e87b3622ff416ad503aedef3df0d0f1d
---
M includes/libs/mime/MimeAnalyzer.php
1 file changed, 10 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/56/364256/1

diff --git a/includes/libs/mime/MimeAnalyzer.php 
b/includes/libs/mime/MimeAnalyzer.php
index 0083e4b..0326a74 100644
--- a/includes/libs/mime/MimeAnalyzer.php
+++ b/includes/libs/mime/MimeAnalyzer.php
@@ -709,8 +709,16 @@
                                        $this->logger->info( __METHOD__ . ": 
recognized file as video/x-matroska\n" );
                                        return "video/x-matroska";
                                } elseif ( strncmp( $data, "webm", 4 ) == 0 ) {
-                                       $this->logger->info( __METHOD__ . ": 
recognized file as video/webm\n" );
-                                       return "video/webm";
+                                       // XXX HACK look for a video track, if 
we don't find it, this is an audio file
+                                       $videotrack = strpos( $head, "\x86\x85" 
);
+
+                                       if ( $videotrack ) {
+                                               $this->logger->info( __METHOD__ 
. ": recognized file as video/webm\n" );
+                                               return "video/webm";
+                                       }
+
+                                       $this->logger->info( __METHOD__ . ": 
recognized file as audio/webm\n" );
+                                       return "audio/webm";
                                }
                        }
                        $this->logger->info( __METHOD__ . ": unknown EBML 
file\n" );

-- 
To view, visit https://gerrit.wikimedia.org/r/364256
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iac749233e87b3622ff416ad503aedef3df0d0f1d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <mholmqu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to