I need to accept only MP4 videos and WMV videos in a Django web app I am building. For that, I am checking the mime type of the file once it hits the server.
As far as I understand, MP4 files have 'video/mp4' mime type, which is exactly what I am receiving on my web app. The problem comes with the WMV files, which according to every site I found (e.g.: this and that) should have 'video/x-ms-wmv' as the mime type. When I get this files on the server and I inspect them using python-magic
I get 'video/x-ms-asf' as its mime type.
I have converted some youtube videos to WMV videos using different online converters but the result is always the same.
So actually, I do not know what am I doing wrong here.
python-magic
is not reading the mime type correctly, which I think would be hardly the case.Any help is deeply appreciated.
As a side note, I am using python-magic
instead of django's file.content_type
because the second is not reliable. Just change the file's extension to the wrong one and file.content_type
will give the extention mime type instead of the real one.
video/x-ms-asf
is the correct MIME type as it is a catch-all for Windows Media files containing audio and video under the "Advanced System Format" family name.
Within the 'family', Audio only files (.wma) can use audio/x-ms-wma
and Video/Audio files (.wmv) can use video/x-ms-wmv
, but for content optimized for streaming it is common to reference the container family rather than the file extension in the MIME type.