From: Mark Holmquist Date: Mon, 10 Jul 2017 17:39:36 +0000 (-0500) Subject: Add (hacky) check for webm audio files X-Git-Tag: 1.31.0-rc.0~2734^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=bef66f7428e64b2aa77b29c8cf034559d0956942;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/libs/mime/MimeAnalyzer.php b/includes/libs/mime/MimeAnalyzer.php index 0083e4b32a..631bb17ebf 100644 --- a/includes/libs/mime/MimeAnalyzer.php +++ b/includes/libs/mime/MimeAnalyzer.php @@ -709,8 +709,17 @@ EOT; $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\x85V_VP" ); + + if ( $videotrack ) { + // There is a video track, so this is a video file. + $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" );