X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2Fmime%2FMimeAnalyzer.php;h=4d860bb593b89dafa2f1ed96992553572f87bc89;hp=0083e4b32a7ce6fc688ec1167d5858ce5cde4ec8;hb=36395150104588f2afea866c330b683e4329fa48;hpb=388fcc23705ab0121646ef771fda7f15efd7e269 diff --git a/includes/libs/mime/MimeAnalyzer.php b/includes/libs/mime/MimeAnalyzer.php index 0083e4b32a..4d860bb593 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" ); @@ -979,18 +988,8 @@ EOT; $m = null; if ( $callback ) { $m = $callback( $file ); - } elseif ( function_exists( "finfo_open" ) && function_exists( "finfo_file" ) ) { - $mime_magic_resource = finfo_open( FILEINFO_MIME ); - - if ( $mime_magic_resource ) { - $m = finfo_file( $mime_magic_resource, $file ); - finfo_close( $mime_magic_resource ); - } else { - $this->logger->info( __METHOD__ . - ": finfo_open failed on " . FILEINFO_MIME . "!\n" ); - } } else { - $this->logger->info( __METHOD__ . ": no magic mime detector found!\n" ); + $m = mime_content_type( $file ); } if ( $m ) {