PHP: how to check MKV or WMV movie format

I use finfo_file and mime_content_type, it returns on MKV and WMV: PHP application / octet stream cannot determine 2 of this video format?

If you need to use the FFMPEG definition (I don’t know if it is possible or not). what is a command to check the format.

+3
source share
3 answers

One thing you can do is read the first few bytes of a file to see if they match known file signatures.

Signature of the MKV file, in particular (in hexadecimal format):

1a 45 df a3

As for WMV, this should be:

30 26 b2 75

See for reference:

Extensible Binary Metalanguage

Advanced system format

+1
source

:

http://www.php.net/manual/en/function.mime-content-type.php#94279

Apache mime.types(Apache/conf/mime.types). .

your/mimetype      mkv
another/type       mvw 

, , script , mime_content_type.

:

, mkv/mvm, , :

http://www.php.net/manual/de/function.mime-content-type.php#91646

0

magic_mime mkv/wmv. , , .

( mkv/wmv):

$handle = finfo_open('FILEINFO_MIME_TYPE', '/path/to/updated/database/file').

You should be able to retrieve the updated database file from the Linux distro fileinfo package.

0
source

Source: https://habr.com/ru/post/1780859/


All Articles