1

I need to define mime type of various video files and I got a problem with .m2ts files. Before I stumbled on this, I used file utility with -iL keys and parsed the output with sed. Today I found that file 5.15 defines mime type of .m2ts files as ‘application/octet-stream’. O-okay, I updated the package and now it calls them just ‘binary’. When I expected video/something.

Reading about utilities doing similar job, I’ve tried xdg-mime query filetype. The problem with xdg-mime is that it looks only at the extension of the file. It defines .m2ts as ‘video/mp2t’, but shows it for any, even an empty text file with such extension.

Maybe it was correct to call .m2ts files a stream because it is actually a stream, but then why in the mime database the extension is bound to ‘video/mp2t’?

$ grep m2ts /usr/share/mime/video/mp2t.xml
  <glob pattern="*.m2ts"/>
1

2 Answers 2

1

Thanks to link provided by @Patrick I understood that file has nothing to do with shared-mime-info and its database is in /usr/share/misc/magic.mgc. So I googled for a ~/.magic file with a fix and found it here. The lines there are lacking spaces so I adduce it here

4 byte 0x47
>5 beshort 0x4000
>>7 byte ^0xF
>>>196 byte 0x47
>>>>388 byte 0x47
>>>>>580 byte 0x47 M2TS MPEG transport stream, v2
!:mime video/MP2T
0

.m2ts is used for multiplexing audio, video and other streams, based on MPEG-2 transport stream container.

RFC 3555 defined many MIME subtypes for MPEG-2 transport stream, include video/mp2t. So I think it is normal when it is bounded to video/mp2t.

1
  • It is normal, but how to force the file to show appropriate mime-type?
    – tijagi
    May 12, 2014 at 18:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .